iron-io / iron_mq_ruby

Ruby library for IronMQ.
http://www.iron.io
BSD 2-Clause "Simplified" License
35 stars 17 forks source link

RestClientExceptionWrapper: HTTP Error #88

Open perlun opened 9 years ago

perlun commented 9 years ago

Hi,

Sometimes, our code runs into the exception noted above. Any ideas about what could be causing this? The code is basically something along these lines:

  def listen_on_queue(queue_name)
    ironmq = IronMQ::Client.new(
      host: IRONMQ_HOST,
      token: IRONMQ_TOKEN,
      project_id: IRONMQ_PROJECT_ID
    )

    @logger.debug "Listening on message queue '#{queue_name}'."
    queue = ironmq.queue(queue_name)

    # Slightly stupid to create a new thread, but the worker reloading malfunctions without it.
    Thread.new do
      begin
        queue.poll(wait: 30) do |m|
          handle_message(m.body)
        end
      rescue => e
        @logger.error 'Exception occurred:'
        @logger.error e
      end
    end
  end

The stack trace is as below:

2014-11-19T22:42:48.6397309Z ERROR [2014-11-19 23:42:48.639] Foo: Caught Rest::Wrappers::RestClientExceptionWrapper: HTTP  Error
2014-11-19T22:42:48.6397309Z    D:/eCraft/uxFactory/PRD/server/gems/jruby/1.9/gems/rest-2.7.2/lib/rest/wrappers/rest_client_wrapper.rb:55:in `get'
2014-11-19T22:42:48.6397309Z    D:/eCraft/uxFactory/PRD/server/gems/jruby/1.9/gems/rest-2.7.2/lib/rest/client.rb:118:in `get'
2014-11-19T22:42:48.6397309Z    D:/eCraft/uxFactory/PRD/server/gems/jruby/1.9/gems/rest-2.7.2/lib/rest/client.rb:142:in `perform_op'
2014-11-19T22:42:48.6397309Z    D:/eCraft/uxFactory/PRD/server/gems/jruby/1.9/gems/rest-2.7.2/lib/rest/client.rb:117:in `get'
2014-11-19T22:42:48.6397309Z    D:/eCraft/uxFactory/PRD/server/gems/jruby/1.9/gems/iron_core-1.0.5/lib/iron_core/client.rb:187:in `get'
2014-11-19T22:42:48.6397309Z    D:/eCraft/uxFactory/PRD/server/gems/jruby/1.9/gems/iron_mq-5.0.1/lib/iron_mq/client.rb:68:in `get'
2014-11-19T22:42:48.6397309Z    D:/eCraft/uxFactory/PRD/server/gems/jruby/1.9/gems/iron_mq-5.0.1/lib/iron_mq/queues.rb:243:in `call_api_and_parse_response'

Any suggestions or ideas? This makes the thread crash, and no more messages gets processed. I guess I could make it slightly more resilient to this, but are there any other good options also?

pyeremenko commented 9 years ago

Hi, @perlun.

Which version of gem do you use?

perlun commented 9 years ago

iron_mq (5.0.1)

Would it be better with bleeding edge (i.e. master from GitHub)?

treeder commented 9 years ago

Strange there is no HTTP error code...

perlun commented 9 years ago

This problem is unfortunately still active, with long-running IronMQ polling:

2015-01-27T18:11:52.1217063Z ERROR [2015-01-27 19:11:52.121] DeploymentWorker: Exception occurred:
2015-01-27T18:11:52.1217063Z ERROR [2015-01-27 19:11:52.121] DeploymentWorker: Caught Rest::Wrappers::RestClientExceptionWrapper: HTTP  Error
2015-01-27T19:50:34.2220423Z ERROR [2015-01-27 20:50:34.222] DeploymentWorker: Exception occurred:
2015-01-27T19:50:34.2220423Z ERROR [2015-01-27 20:50:34.222] DeploymentWorker: Caught Rest::Wrappers::RestClientExceptionWrapper: HTTP  Error

Any ideas/suggestions?

featalion commented 9 years ago

@perlun do you using IronMQ v3 or v2 API?

perlun commented 9 years ago

No idea, so I assume v2? I use the default settings AFAIK.

featalion commented 9 years ago

I see in the log you posted above, that errors happen rare (1h40m in the example). Could you please check in your log how often it happens? Are errors like "service unreachable" happen nearby in time?