dropbox / amqp-coffee

An AMQP 0.9.1 client for Node.js.
MIT License
79 stars 30 forks source link

Publish hangs forever after connection loss (reconnect = false) #82

Open shumsky opened 7 years ago

shumsky commented 7 years ago

Hi,

I'm using amqp-coffee with reconnect = false option. Below is an example that reproduces the issue I faced recently. The example is a simple producer that publishes new message every second:

const AMQP = require('amqp-coffee');

const amqp = new AMQP({host: 'localhost', reconnect: false});

setInterval(() => {
  amqp.publish('coffee:test', '', 'hello', {}, (err) => {
    if (err) return console.log('Error: ' + err);
    console.log('Published');
  });
}, 1000);

The scenario is following:

  1. run the example script
  2. wait until at least one message is published
  3. shut down message broker server

Expected result: Option 1. For all next publishes the callback is invoked with an error Option 2. The process crashes because of unhandled exception

Actual result: Next publishes hang forever. Callbacks are never called. As I understand, publish waits until connection is back, but since reconnect is disabled it never happens.

What do you think?