iron-io / iron_mq_ruby

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

JSON::ParserError: A JSON text must at least contain two octets! #97

Closed almathie closed 8 years ago

almathie commented 9 years ago

I am encountering a lot of errors in airbrake ATM, those seems to come form the iron gem : Due to some changes on my end, it is possible that messages are not acked within the designed timeout.

JSON::ParserError: A JSON text must at least contain two octets!
/gems/json-1.8.3/lib/json/common.rb:155 in initialize
/gems/json-1.8.3/lib/json/common.rb:155 in new
/gems/json-1.8.3/lib/json/common.rb:155 in parse
/gems/iron_core-1.0.5/lib/iron_core/client.rb:196 in extract_error_msg
/gems/iron_core-1.0.5/lib/iron_core/client.rb:189 in rescue in get
/gems/iron_core-1.0.5/lib/iron_core/client.rb:186 in get
/gems/iron_mq-5.0.1/lib/iron_mq/client.rb:68 in get
/gems/iron_mq-5.0.1/lib/iron_mq/queues.rb:243 in call_api_and_parse_response
/gems/iron_mq-5.0.1/lib/iron_mq/queues.rb:194 in get_messages
/gems/iron_mq-5.0.1/lib/iron_mq/queues.rb:223 in poll_messages
/some/of/my/code/file.rb:260 in start

Here is my code arnoud line 260

begin
  queue_base_name = "QUEUE"
  sleep_time_when_empty_queue = 15
  while true
    # Just below is line 260
    ironmq.queue(queue_base_name).poll(sleep_duration: sleep_time_when_empty_queue, timeout: 3600, wait: 30) do |message|
      puts "[#{Time.now}] start IRON MQ message"
      # This can be quite long
      self.execute message.body
      puts "[#{Time.now}] end IRON MQ message"
    end
  end
rescue Interrupt => e
  STDERR.puts "[#{Time.now}] Error : #{e}"
end
treeder commented 9 years ago

Could you try updating your iron_core gem to 1.0.9? There's a fix in there that should show the real error rather than the json parsing error.

rdallman commented 8 years ago

https://github.com/iron-io/iron_mq_ruby/issues/97#issuecomment-140896537 should resolve, please re open if issue persists. thanks!