[rabbitmq-discuss] Reconnecting to RabbitMQ after disconnection not working?

Thanh Pham Van thanhpv at vega.com.vn
Tue Mar 11 11:35:37 GMT 2014


i met the same problem, but i can't find the way to  fix this. Please show 
me more detail.

rgds

On Saturday, March 2, 2013 12:04:50 AM UTC+7, Kelly Elias wrote:
>
> I have a class that connects to RabbitMQ like this: (C# code)
>
> private static ConnectionFactory factory;
> private static IConnection connection;
> private static IModel model;
> private static EventingBasicConsumer consumer;
>
> ...
>
>
> factory = new ConnectionFactory {HostName = address};
> factory.RequestedHeartbeat = 30;
> connection = factory.CreateConnection();
>
> connection.ConnectionShutdown += connection_ConnectionShutdown;
>
> model = connection.CreateModel();
>
> lock (model)
> {
>     model.ExchangeDeclare(EXCHANGE_NAME, "topic");
>     queueName = model.QueueDeclare();
>     consumer = new EventingBasicConsumer();
>     consumer.Received += consumer_Received;
>     model.BasicConsume(queueName, true, consumer);
> }
>
> It all works fine. If I unplug my network connection and wait that 30 
> seconds for the heartbeat the code will realize it's no longer connected 
> and attempt to reconnect by running the code above again. I don't get any 
> errors, but after the re-connection I never get a message from RabbitMQ.
>
> I've tried to dispose the objects I'm using but if I try with the 
> connection it hangs and never returns.
>
> Any ideas what I can try?
>
>
> I'm using server version 2.4.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140311/7206855b/attachment-0001.html>


More information about the rabbitmq-discuss mailing list