[rabbitmq-discuss] subscriber failed to detect closed connection

Tim Watson tim at rabbitmq.com
Thu Aug 2 16:04:41 BST 2012


Hi Mark,

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

On 08/02/2012 03:58 PM, 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();
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120802/6399e88a/attachment.htm>


More information about the rabbitmq-discuss mailing list