Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heartbeat troubles #26

Closed
ghost opened this issue Apr 15, 2015 · 7 comments
Closed

heartbeat troubles #26

ghost opened this issue Apr 15, 2015 · 7 comments

Comments

@ghost
Copy link

ghost commented Apr 15, 2015

I have same bug described in #23

Connection is closing after [heartbeat * 3] ms

Here is code which can reproduce bug on my localhost rabbit (mac) and server rabbit (ubuntu:
https://gist.github.com/vkfont/65d77cf461c075ebba60

Andreys-MacBook-Air:mservice-utils drago$ node debug/test
connected to rabbit@Andreys-Air v3.5.0
queue "amq.gen-xm_fKnPv_bzjKuguX8KsQQ" created
connection is closed: 30000ms
connected to rabbit@Andreys-Air v3.5.0
events.js:87
      throw Error('Uncaught, unspecified "error" event.');
            ^
Error: Uncaught, unspecified "error" event.
    at Error (native)
    at Consumer.emit (events.js:87:13)
    at Consumer._channelClosed (/Users/drago/Documents/ark/mservice-utils/node_modules/amqp-coffee/bin/src/lib/Consumer.js:183:14)
    at Consumer._channelClosed (/Users/drago/Documents/ark/mservice-utils/node_modules/amqp-coffee/bin/src/lib/Consumer.js:4:61)
    at Consumer.Channel._onChannelMethod (/Users/drago/Documents/ark/mservice-utils/node_modules/amqp-coffee/bin/src/lib/Channel.js:326:16)
    at Connection._onMethod (/Users/drago/Documents/ark/mservice-utils/node_modules/amqp-coffee/bin/src/lib/Connection.js:571:39)
    at AMQPParser.<anonymous> (/Users/drago/Documents/ark/mservice-utils/node_modules/amqp-coffee/bin/src/lib/Connection.js:4:61)
    at AMQPParser.emit (events.js:118:17)
    at AMQPParser.parseMethodFrame (/Users/drago/Documents/ark/mservice-utils/node_modules/amqp-coffee/bin/src/lib/AMQPParser.js:110:19)
    at AMQPParser.frameEnd (/Users/drago/Documents/ark/mservice-utils/node_modules/amqp-coffee/bin/src/lib/AMQPParser.js:80:16)
@barshow
Copy link
Contributor

barshow commented Apr 15, 2015

perfect I was able to reproduce this, ill have a fix for you to try shortly

@barshow
Copy link
Contributor

barshow commented Apr 16, 2015

@vkfont can you give this branch a try

https://github.com/dropbox/amqp-coffee/tree/feature/0.1.21
#27

Pending your approval ill merge it in. Thanks for the report!

@ghost
Copy link
Author

ghost commented Apr 16, 2015

Seems to be working. At least i cant repeat this bug.
Thanks for the quick response.

@ghost
Copy link
Author

ghost commented Apr 16, 2015

Also found error with this code https://gist.github.com/vkfont/65d77cf461c075ebba60 on branch feature/0.1.21:

  1. Launch code
  2. Unload/disable rabbitmq service
  3. Load/enable rabbitmq service

Output is:

Andreys-MacBook-Air:amqp-coffee drago$ node test.js
connected to rabbit@Andreys-Air v3.5.0
queue "amq.gen-axfmQwVfBvqjW-55PvKWww" created
connection is closed: 5954ms
(node) warning: possible EventEmitter memory leak detected. 11 open listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at Publisher.addListener (events.js:179:15)
    at Publisher.once (events.js:204:8)
    at Publisher.publish (/Users/drago/Documents/amqp-coffee/bin/src/lib/Publisher.js:91:23)
    at /Users/drago/Documents/amqp-coffee/bin/src/lib/Connection.js:307:31
    at ChannelManager.publisherChannel (/Users/drago/Documents/amqp-coffee/bin/src/lib/ChannelManager.js:69:16)
    at ChannelManager.publisherChannel (/Users/drago/Documents/amqp-coffee/bin/src/lib/ChannelManager.js:15:61)
    at Connection.publish (/Users/drago/Documents/amqp-coffee/bin/src/lib/Connection.js:296:34)
    at Connection.publish (/Users/drago/Documents/amqp-coffee/bin/src/lib/Connection.js:4:61)
    at /Users/drago/Documents/amqp-coffee/test.js:39:22
    at Immediate.next [as _onImmediate] (/Users/drago/Documents/amqp-coffee/node_modules/async/lib/async.js:1103:13)
connected to rabbit@Andreys-Air v3.5.0
events.js:87
      throw Error('Uncaught, unspecified "error" event.');
            ^
Error: Uncaught, unspecified "error" event.
    at Error (native)
    at Consumer.emit (events.js:87:13)
    at Consumer._channelClosed (/Users/drago/Documents/amqp-coffee/bin/src/lib/Consumer.js:183:14)
    at Consumer._channelClosed (/Users/drago/Documents/amqp-coffee/bin/src/lib/Consumer.js:4:61)
    at Consumer.Channel._onChannelMethod (/Users/drago/Documents/amqp-coffee/bin/src/lib/Channel.js:326:16)
    at Connection._onMethod (/Users/drago/Documents/amqp-coffee/bin/src/lib/Connection.js:601:39)
    at AMQPParser.<anonymous> (/Users/drago/Documents/amqp-coffee/bin/src/lib/Connection.js:4:61)
    at AMQPParser.emit (events.js:118:17)
    at AMQPParser.parseMethodFrame (/Users/drago/Documents/amqp-coffee/bin/src/lib/AMQPParser.js:110:19)
    at AMQPParser.frameEnd (/Users/drago/Documents/amqp-coffee/bin/src/lib/AMQPParser.js:80:16)

Expected behavior: script should work

@barshow
Copy link
Contributor

barshow commented Apr 16, 2015

Potentially, the problem is the queue you're declaring is auto deleted, and the consumer is trying to consume a queue that doesn't exist when it reconnects.

You can catch this error from the consumer like this.
https://gist.github.com/barshow/cbce578e839e04b7da65

You could disable auto reconnect on the consuming connection, and on disconnect set everything back up. The connection would emit a close event. It also emits a close event before it attempts to reconnect.

If you have any idea's on how these errors should be handled I would love to hear them :)

@ghost
Copy link
Author

ghost commented Apr 16, 2015

In my case setting 'autoDelete' to false does not help.
Im getting msg: 'Server closed channel' if autodelete is set - thats fine.

But if i'll set autoDelete = false, durable = true and restart rabbitmq - named channel stop receiving messages (or publisher stops send?) and no errors raised. This behaviour does not correspond to documentation: Publisher channels, will only reconnect when a publish is atempted and Consumer channels will reconnect and resume consuming. Please correct me if i wrong.

https://gist.github.com/vkfont/65d77cf461c075ebba60

...
receive message
receive message
connection is closed: 3062ms
connected to rabbit@Andreys-Air v3.5.0
...

UPDATE: looks my code was incorrect (wrong callback binding in .publish), everything works fine

@ghost ghost closed this as completed Apr 16, 2015
@barshow
Copy link
Contributor

barshow commented Apr 16, 2015

glad to hear it... ill probably land this on master today or tomorrow

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant