I had an issue when I ack some messages who come from a queue that was marked as non-ack. So calling basicAck or basicNack was throw an error.
This issue was solved and my system now is running as expected but was sad not found a way to detect channel close event to be able to recreate/reconnect that channel.
I have:
// Connect and create a channel to RabbitMQ
this.client = new AMQPClient(connectionUrl)
this.connection = await this.client.connect()
this.channel = await this.connection.channel()
this.client.onerror = (error) => {
console.error(error)
this.tryReconnect()
}
// Handle disconnection
this.connection.onerror = () => {
console.error(
`[RabbitMqClient] ${new Date().toISOString()} Upps! We have a connection error... Trying to reconnect with exponential backoff..`
)
this.tryReconnect()
}
But this only work when RabbitMQ server goes down not when the channel crash.
I had an issue when I ack some messages who come from a queue that was marked as non-ack. So calling basicAck or basicNack was throw an error.
This issue was solved and my system now is running as expected but was sad not found a way to detect channel close event to be able to recreate/reconnect that channel.
I have:
But this only work when RabbitMQ server goes down not when the channel crash.