[rabbitmq-discuss] .Net RabbitMQ.Client Issue: Deadlock on ConnectionShutdown

Emile Joubert emile at rabbitmq.com
Tue Aug 21 11:49:07 BST 2012


Hi Derek,

On 20/08/12 19:29, Derek Greer wrote:
> There appears to be a deadlock if you attempt to dispose, close, or
> abort a channel within the context of an IConnection.ConnectionShutdown
> event.

Instead of deadlock I get an IO exception. An attempt to close the
channel requires network access, but it is no longer possible for the
channel to communicate over the network.

System.IO.IOException:
 Unable to write data to the transport connection:
 An existing connection was forcibly closed by the remote host.
System.Net.Sockets.SocketException:
 An existing connection was forcibly closed by the remote host

> if (channel != null && channel.IsOpen)
> {
> Console.WriteLine("Closing channel ...");
> channel.Close(); // <- Never returns
> Console.WriteLine("Channel closed.");
> }

This code is flawed, because the state of the channel could change
between the query and the action. There is no need to explicitly shut
down the channel when the connection shuts down as this will be done by
the library. Parties can register their interest in channel shutdown
using IModel.ModelShutdown.


-Emile



More information about the rabbitmq-discuss mailing list