[rabbitmq-discuss] subscriber failed to detect closed connection

Mark Ward ward.mark at gmail.com
Thu Aug 2 16:24:36 BST 2012

Hi Tim,

Thanks, I found the heartbeat property on the connection class. 
connectionFactory.RequestedHeartbeat   I didn't realize it was default off 
(0) and will test with a value.


Hi Mark,

You should try enabling AMQP heartbeats, as this should resolve the issue 
of detecting the connection is being closed.  

On Thursday, August 2, 2012 9:58:51 AM UTC-5, Mark Ward wrote:
> Hi,
> I am performing tests to a server across the internet.  During the night 
> our firewall is rebooted and it appears the basic consumer is not detecting 
> this and does not throw any exceptions on the connection.  When I arrive to 
> the office each morning the subscriber client is still running and in the 
> block state waiting for a message.  If I send messages to the server the 
> client will not receive messages unless I restart the client.  The client 
> works all day long as I push millions of messages through for testing.  It 
> is after the firewall reset that the client does not continue to work or 
> fail out.  This does appear to be a repeatable issue for the past two days 
> it has performed this same issue.  I am going to continue tonight to see if 
> it repeats.
> Is there something I need to enable to have the client detect the 
> connection closure?  The testing I have manually performed on closing the 
> network connection, shutting down the server, restarting the server have 
> all caused the client to properly throw and exception that the connection 
> was closed.  It is only when the firewall resets that the client does not 
> detect the failed connection. 
> This is the .NET client connecting to the port 5672.  It is not using SSL.
> below is the example code I am working with.
> var connectionFactory = new ConnectionFactory();
>             connectionFactory.HostName = hostName;
>             connectionFactory.Port = port;
>             IConnection connection = connectionFactory.CreateConnection();
>             IModel channel = connection.CreateModel();
>             QueueingBasicConsumer consumer = new 
> QueueingBasicConsumer(channel);
>             String consumer_tag = channel.BasicConsume("QueueOne", false, 
> consumer);
>             Console.WriteLine("ctrl+c to exit");
>             while (true)
>             {
>                 BasicDeliverEventArgs evt_args = 
> (BasicDeliverEventArgs)consumer.Queue.Dequeue();
>                 IBasicProperties msg_props = evt_args.BasicProperties;
>                 string message = Encoding.UTF8.GetString(evt_args.Body);
>                 channel.BasicAck(evt_args.DeliveryTag, false);
>                 Console.WriteLine("Message Body: " + message);
>             }
>             channel.Close();
>             connection.Close();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120802/ded1b46b/attachment.htm>

More information about the rabbitmq-discuss mailing list