Hominid exception error with EOF reached file - ruby

I am using hominid gem for Rails 3 for to connect with MailChimP API. I write a class with many methods for my problem domain.
I need a rake task which run each X time. My problem is when i test the hominid methods.
Each X time hominid gem raise a exception with EOF Reached file error.
I test my methods many time without to change arguments. sometimes run very well while other times throw this exception.
I also test my methods calling from console and controller action.
There occurs same problem.
How could I sync hominid API calls?
Which could be the problem?
Thanks in advance

Related

Capybara with selenium throws Net::ReadTimeout error Intermittently when using `visit` method with cucumber

I am getting Net::ReadTimeout error when using visit methods in a cucumber feature. Unfortunately, I am not able to reproduce this issue on my local system, it only intermittently fail on semaphore. We are using 20 parallel threads in semaphore.
The weired thing is I can see the screen shot of the page using capybara screenshot but still get the timeout error
Here is the test
RSpec.feature do
step 'that I have created a questionnaire' do
safe_visit '/somesite' # getting error on this line sometime
fill_in 'name', with: 'punit'
end
end
We are using rutabaga which is wrapper over turnip gem and allow to run features as rspecs.
What I have already tried (and did not work):
Increase timeout to 120 and retries Net::ReadTimeout (Net::ReadTimeout) Selenium Ruby
Add the selenium driver desired capabilities
Getting Net::ReadTimeout: visiting a website in Ruby Capybara Cucumber
NOTE: Please dont mark this as a duplicate of any other question because I have done a lot of search for quite a few days and then posted this question. Also one key difference in my issue is it is flakey and only happened rarely.
Please let me know in comment if I need any more info is needed.

Ruby Undefined Method, Metasploit

I've been trying to get credentials hashes on a windows meterpreter session, but each time i run "run post/windows/gather/hashdump" i get the following error:
Post failed: NoMethodError undefined method unpack' for nil:NilClass
Call stack:
/usr/share/metasploit-framework/modules/post/windows/gather/hashdump.rb:42:inrun'
the unpack() method is used through all of the hashdump.rb script but as the meterpeter session tells it's not defined.
I've never used ruby before, so i don't know whether it's a predefined method or should i define it, nor how to do it.
Any help is appreciated.
Thanks.
It looks like hashdump is failing to retrieve the boot key from the system registry. My best guess is that you're trying to run hashdump without system privileges.
With insufficient access, the script returns nil instead of the boot key, then tries to unpack nil which causes a fairly unhelpful NoMethodError.
Try running getsystem before you run hashdump.

ActiveJob::DeserializationError: Error while trying to deserialize arguments

I am trying to send mail in production but it is throwing Activejob deserailization error.sidekiq is running in background. I have added sidekiq gem. I wrote one method in comment_notification.rb for sending email to the user. Then in controller in create action I have added this
def create
CommentNotification.send_comment_mail(#current_user).deliver_later(wait: 1.minute)
end
def send_comment_email(current_user)
mail( to: current_user.email,
:subject => "commented on post",
:from => "<noreply#xxx.com>")
end
It was working fine in local server but in production I am getting this error
/home/apps/commentpost/shared/bundle/ruby/2.3.0/gems/sidekiq-4.2.3/lib/sidekiq/processor.rb:69:in `run'
/home/apps/commentpost/shared/bundle/ruby/2.3.0/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:17:in `watchdog'
/home/apps/commentpost/shared/bundle/ruby/2.3.0/gems/sidekiq-4.2.3/lib/sidekiq/util.rb:25:in `block in safe_thread'
2016-11-18T06:47:16.162Z 19093 TID-uw66g ActionMailer::DeliveryJob JID-e56b150964abf082e78089d9 INFO: start
2016-11-18T06:47:16.167Z 19093 TID-uw66g ActionMailer::DeliveryJob JID-e56b150964abf082e78089d9 INFO: fail: 0.005 sec
2016-11-18T06:47:16.167Z 19093 TID-uw66g WARN: {"context":"Job raised exception","job":{"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"ActionMailer::DeliveryJob","queue":"mailers","args":[{"job_class":"ActionMailer::DeliveryJob","job_id":"96e06bc6-1380-47b9-9393-9727868b3897","queue_name":"mailers","priority":null,"arguments":["CommentNotification","send_comment_email","deliver_later",{"_aj_globalid":"gid://commentpost/comment/40"},{"_aj_globalid":"gid://commentpost/User/20"}],"locale":"en"}],"retry":true,"jid":"e56b150964abf082e78089d9","created_at":1479450405.8364522,"enqueued_at":1479451636.1602836,"error_message":"Error while trying to deserialize arguments: Couldn't find Comment with 'id'=40","error_class":"ActiveJob::DeserializationError","failed_at":1479450405.8429642,"retry_count":6,"retried_at":1479451636.1668367},"jobstr":"{\"class\":\"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper\",\"wrapped\":\"ActionMailer::DeliveryJob\",\"queue\":\"mailers\",\"args\":[{\"job_class\":\"ActionMailer::DeliveryJob\",\"job_id\":\"96e06bc6-1380-47b9-9393-9727868b3897\",\"queue_name\":\"mailers\",\"priority\":null,\"arguments\":[\"CommentNotification\",\"send_comment_email\",\"deliver_later\",{\"_aj_globalid\":\"gid://commentpost/comment/40\"},{\"_aj_globalid\":\"gid://commentpost/User/20\"}],\"locale\":\"en\"}],\"retry\":true,\"jid\":\"e56b150964abf082e78089d9\",\"created_at\":1479450405.8364522,\"enqueued_at\":1479451636.1602836,\"error_message\":\"Error while trying to deserialize arguments: Couldn't find Comment with 'id'=40\",\"error_class\":\"ActiveJob::DeserializationError\",\"failed_at\":1479450405.8429642,\"retry_count\":5,\"retried_at\":1479450981.998904}"}
2016-11-18T06:47:16.167Z 19093 TID-uw66g WARN: ActiveJob::DeserializationError: Error while trying to deserialize arguments: Couldn't find Comment with 'id'=40
2016-11-18T06:47:16.167Z 19093 TID-uw66g WARN: /
Could anyone please help me regarding this doubt? For this I will be thankful.
As I understand correctly the create method in controller creates also the comment and sends the email for the freshly created comment?
Then it would be better to use a callback here.
We had the same issue in our project and we solved it by using something like that:
# in model
after_commit :send_mail, on: :create
private
def send_mail
CommentNotification.send_comment_mail(campaign.user).deliver_later
end
Then you can be sure that the record really exists in the Database before the mail gets delivered.
The problem here is, that you run a Comment#create and enqueue the mail in the controller. Now it can happen, that Sidekiq runs the task before Rails commits the new comment.
And then you get exactly this error.
Regards,
spa
When I ran into an issue with seemingly simple errors being raised due to the record not being the database (it was!), I found out that my Sidekiq workers were running in test mode and were able to dequeue jobs whose database records were supposed to be in the development database.
I was able to debug this after some trial and error in the stack trace by inspecting ActiveRecord::Base.connection's connection_parameters instance variable - it was pointing to the test database!
Looking through the Sidekiq logs, I was able to see that it was starting up workers to execute jobs against the test environment and database. My specific issue was also caused by spring. Disabling its use by invoking bundle exec sidekiq ... instead of sprint sidekiq fixed my issue.

Stack Level Too Deep in multi_json adapter logic

I have a rspec suite that runs perfectly on OS X, but fails on ubuntu for all specs that call a specific method.
The error I am seeing is:
SystemStackError - stack level too deep:
/home/ubuntu/.rvm/gems/ruby-1.9.3-p194#testset/gems/multi_json-1.5.0/lib/multi_json.rb:75
As shown I have a dependancy on active_support, which requires multi_json. This line is requiring the adapter for json_gem, all of this seems internal to the request parsing. The actual error occurs in the request parsing of the endpoint, somewhere inside of sinatra. None of my code is ever hit (my debug statement never gets hit).
As for the method, it is hitting a running test endpoint with a POST containing a small, preset JSON string as the body.
Help greatly appreciated!

mysql timeout error in rails 3 when using delete_all and make! in step definition

I'm using following construct in a cucumber step definition.
Given "I have following stuff" do
Model.delete_all
list.each { |i| Model.make!(:name => i) }
end
(make! is from machinist 2).
Above step fails with INSERT statement timeout. When I open up a console for test, environment, I can execute each statement without an issue. Also, if I disable transactional features timeout goes away.
Can anyone please help me fix this? (This ran without an issue with rails 2.x)
(Database MySQL)
This turned out be an issue with machinist beta version I was using. I'm not 100% sure what was wrong, but when I used pure ActiveRecord code to create the objects, instead of make! it worked.
Then I switched to Factory_Girl instead of machinist, and now it works fine.

Resources