Hi. My company Heyzap recently start using Bunny to connect to RabbitMQ from our Rails servers (using Unicorn/Resque). We've been using RabbitMQ with our java services for awhile without any issues, but Ruby-side we've regularly been getting this exception:
Trying to send frame through a closed connection. Frame is #<AMQ::Protocol::MethodFrame:0x00000016886ce0 @payload="\x00<\x00(\x00\x00\btimecube\ftimecube.sdk\x00", @channel=1>, method class is AMQ::Protocol::Basic::Publish
These errors are proceeded by a few timeout errors, which I think is the root cause:
[GEM_ROOT]/gems/bunny-1.7.0/lib/bunny/concurrent/continuation_queue.rb:25:in `pop'
[GEM_ROOT]/gems/bunny-1.7.0/lib/bunny/concurrent/continuation_queue.rb:25:in `block in poll'
/usr/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
/usr/lib/ruby/2.1.0/timeout.rb:101:in `call'
/usr/lib/ruby/2.1.0/timeout.rb:101:in `timeout'
[GEM_ROOT]/gems/bunny-1.7.0/lib/bunny/concurrent/continuation_queue.rb:24:in `poll'
This happened without a heartbeat (the Bunny default) and with a heartbeat of 300 seconds (the server's value is the default of 580). When the exceptions start, I need to restart the unicorns to resolve the issue.
I think that some code may be blocking Ruby and contributing to the timeout errors. Notably, these errors would instantly get triggered when a colleague's code started several threads, then called "join" on them while they uploaded files to S3.
The rabbitMQ logs are filled accepting AMQP connection and closing AMQP connection (connection_closed_abruptly) (
sample of the logs). These messages happen all the time, so I'm not sure they're related to the exceptions we're seeing.
Any advice on what might be causing the exceptions, and how to fix it? Should we increase the continuation_timeout from 4000 ms? Any ideas on why these exceptions don't seem to go away after they start (which I presume they would if we were able to reconnect to RabbitMQ)?
Version Info:
Ruby: 2.1.2
Bunny: 1.7.0
amq-protocol: 1.9.2