node-amqp-connection-manager
node-amqp-connection-manager copied to clipboard
channelWrapper.checkQueue caused connection disconnect, it should only bork the channel, not connection
this is my code:
const conn = await amqpConnManager.connect([options])
const ch =conn.createChannel()
await ch.waitForConnect()
ch.checkQueue('test-queue-name')
when queue is not exist this may cause connection disconnect. but in amqplib api(https://amqp-node.github.io/amqplib/channel_api.html#channel_checkQueue), checkQueue error only bork the channel,not connection.
whew, I just encountered same error, waste me about two days or so...
in case you still wondering the reason and solution,
It seems like channelWrapper's event handler does not apply to underlying channel,
so since you don't have .on('error')
handler attach to channel, every channel exception will escape
and cause your connection disconnected, here is my working snippet:
const channelWrapper = conn.createChannel({
setup: async (ch: amqplib.ConfirmChannel) => {
ch.on('error', (err) => {
console.log(err)
})
}
})
you can handle it inside setup function, so channel exception will be handled in error handler
I tried the above code but it only catches the error, the mq server is not responding anymore, i guess because it has not reconnected.