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

Missing reconnect and 'close' event #27

Closed
mrjensen opened this issue May 1, 2018 · 0 comments
Closed

Missing reconnect and 'close' event #27

mrjensen opened this issue May 1, 2018 · 0 comments

Comments

@mrjensen
Copy link

mrjensen commented May 1, 2018

Hi and thank you for the project 👍

I was testing some error scenarios and found unexpected behaviour when using the Connection class' reconnectStrategy.

  1. reconnect doesn't happen if the connection is closed due to "CONNECTION-FORCED"
  2. after a successful reconnect, the 'close' callback isn't invoked

amqp-ts seems to handle closing connections differently in scenario 1 and 2. Scenario 1 works as expected while scenario 2 doesn't reconnect, but leaves consumers hanging as if nothing happened.

By hooking up the 'close' callback, I see that only Scenario 1 results in a isFatalError=true from the dependency amqplib. The 'close' callback also allows me to detect that Scenario 2 doesn't reconnect and results in isFatalError=false.

If Scenario 1 happens, the 'close' callback is only invoked on the first 'close' event. Since I have to handle Scenario 2 manually this unfortunately renders the reconnect feature unuseful for me, since I can't handle the manual reconnects if a successful reconnect has already happened.

Scenario 1: reconnects as expected ✅

  1. amqp-ts connects (successfully) to a rabbit-instance in a 3-node cluster
  2. terminate the rabbitmq instance the client connected to (with kill -9 <PID>)
  3. amqp-ts reconnects
  4. (repeat step 2 and 3)
    Setting up a callback on 'close' shows that amqplib's isFatalError returns true.

Scenario 2: reconnect doesn't happen on CONNECTION-FORCED ❌

  1. amqp-ts connects (successfully) to a rabbit-instance in a 3-node cluster
  2. restart the rabbitmq service (Ubuntu) the client connected to (with sudo systemctl restart rabbitmq-server.service)
  3. no reconnect
  4. 'close' callback is invoked and consumer is hanging without consuming events
    Setting up a callback on 'close' shows that amqplib's isFatalError returns false and error: "Connection closed: 320 (CONNECTION-FORCED) with message "CONNECTION_FORCED - broker forced connection closure with reason 'shutdown'".

Scenario 3: 'close' callback isn't invoked after succesfull reconnect (scenario 1) ❌

  1. amqp-ts connects (successfully) to a rabbit-instance in a 3-node cluster
  2. terminate the rabbitmq instance the client connected to (with kill -9 <PID>)
  3. amqp-ts reconnects
  4. restart the rabbitmq service (Ubuntu) the client connected to (with sudo systemctl restart rabbitmq-server.service)
  5. 'close' callback is NOT invoked and consumer is hanging without consuming events
alavers added a commit to zendesk/amqp-ts that referenced this issue Jan 9, 2019
Fixes a bug where amqp-ts would fail to reconnect in the event that a
node in a RabbitMQ cluster was cycled. In this case, amqplib emits a
close event which amqp-ts fails to listen for. Fixes
abreits#27
alavers added a commit to zendesk/amqp-ts that referenced this issue Jan 10, 2019
Fixes a bug where amqp-ts would fail to reconnect in the event that a
node in a RabbitMQ cluster was cycled. In this case, amqplib emits a
close event which amqp-ts fails to listen for. Fixes
abreits#27
alavers added a commit to zendesk/amqp-ts that referenced this issue Jan 12, 2019
Fixes a bug where amqp-ts would fail to reconnect in the event that a
node in a RabbitMQ cluster was cycled. In this case, amqplib emits a
close event which amqp-ts fails to listen for. Fixes
abreits#27
alavers added a commit to zendesk/amqp-ts that referenced this issue Jan 12, 2019
Fixes a bug where amqp-ts would fail to reconnect in the event that a
node in a RabbitMQ cluster was cycled. In this case, amqplib emits a
close event which amqp-ts fails to listen for. Fixes
abreits#27
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