You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into this problem where I'd do and action that caused the server to close the channel Example: publishing to a missing exchange. I expected the channel to be recreated but I get stuck with a closed/broken channel. If I cause a disconnection from Rabbitmq the channel gets recreated and everything works again.
Is this the expected behavior? Is there a better way of handling this case?
Here's an example with the workaround I'm using for the moment.
constamqp=require('amqp-connection-manager');constclient=amqp.connect('amqp://admin:admin@localhost:5672');constchannelWrapper=client.createChannel({setup: (channel)=>{console.log('setup channel');// add this hack to reconnect if the server closes the connection (workaround)channel.on('close',()=>{if(channel.sendMessage===channel.sendOrEnqueue){channelWrapper._onConnect({connection: channelWrapper._connectionManager.connection});}});setTimeout(async()=>{try{awaitchannel.publish('missing_exchange','',Buffer.from('msg'));}catch(err){console.log('published to wrong exchange server closes channel',err);}},1000);returnchannel;}});
The text was updated successfully, but these errors were encountered:
anzerr
changed the title
channels closed from server do not reconnect
Channels closed from server do not reconnect
Aug 17, 2023
I ran into this problem where I'd do and action that caused the server to close the channel
Example: publishing to a missing exchange
. I expected the channel to be recreated but I get stuck with a closed/broken channel. If I cause a disconnection from Rabbitmq the channel gets recreated and everything works again.Is this the expected behavior? Is there a better way of handling this case?
Here's an example with the workaround I'm using for the moment.
The text was updated successfully, but these errors were encountered: