amqp-coffee icon indicating copy to clipboard operation
amqp-coffee copied to clipboard

Connection continuously emits 'error' after the underlying socket died (reconnect = false)

Open shumsky opened this issue 8 years ago • 0 comments

Hi,

I'm using amqp-coffee with reconnect=false in one of my projects. During testing of some negative scenarios I faced a little bit odd behaviour. Here's a code example:

const amqp = new AMQP({host: 'localhost', reconnect: false});
amqp.consume('coffee:test:q', {}, (msg) => { /* ... */ });
amqp
  .on('error', (e) => console.log('ERROR: ' + e))
  .on('close', () => console.log('CLOSE'))

I run the program above and then manually take the local RabbitMQ server down. What I get in stdout is:

CLOSE
ERROR: Error: This socket has been ended by the other party
ERROR: Error: This socket has been ended by the other party
ERROR: Error: This socket has been ended by the other party
...

The Connection doesn't emit error only once, but continues emitting it every 10 seconds. As far as I see, it happens because of heartbeat timer which keeps triggering after the error. What I would rather expect is that once an error is emitted, the connection cancels all its internal timers.

What are your thoughts?

shumsky avatar Aug 08 '17 15:08 shumsky