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

channelWrapper.checkQueue caused connection disconnect, it should only bork the channel, not connection #274

Open
shuidian opened this issue Aug 16, 2022 · 2 comments

Comments

@shuidian
Copy link

shuidian commented Aug 16, 2022

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.

@s60912frank
Copy link

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

@dsoyez
Copy link

dsoyez commented Jun 16, 2023

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.

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

3 participants