[rabbitmq-discuss] Consumers may hang after network instability

Alexey gmlexx at gmail.com
Fri Feb 17 10:22:05 GMT 2012


We are using 2.7.1 version of .NET client and 2.7.1 rabbitmq-server.
Several times we catched all consumers of rabbitmq server was hang
after network instability (lost and reestablished connection or server
with rabbitmq power cable unpluged)

Problem method is IModel.Close() or IConnection.Close() (sorry, I
don't remember which is)

Parts of our code responded for connection below:

public void Connect()
	var cf = new ConnectionFactory
		HostName = replica.EndPoint.Address.ToString(),
		Port = replica.EndPoint.Port,
		UserName = mqUsername,
		Password = mqPassword,
	connection = cf.CreateConnection();
	Model = connection.CreateModel();
	Model.BasicConsume(queueName, false, thisConsumerTag, true, false,
null, this);

public void Disconnect(){
	if (Model != null && Model.IsOpen) Model.Close(200, "Close on client
	if (connection != null && connection.IsOpen) connection.Close(200,
"Close on client initiative", disconnectTimeout);

Can anyone suggest a right way to close connection without chance to
Would appreciate for help.

More information about the rabbitmq-discuss mailing list