-
Notifications
You must be signed in to change notification settings - Fork 612
Closed
Description
This happens both using NuGet package 5.1.2 and the latest master code. RabbitMQ server 3.7.25.
If the connection is closed by the server, e.g. by clicking "Force Close" in on the management web page, and the client then aborts the connection, the following exception occurs on the client (every time):
System.NullReferenceException
RabbitMQ.Client.dll!RabbitMQ.Client.Impl.SocketFrameHandler.WriteFrame(RabbitMQ.Client.Impl.OutboundFrame frame, bool flush) Line 235
at C:\W ork\rabbitmq-dotnet-client\projects\RabbitMQ.Client\client\impl\SocketFrameHandler.cs(235)
RabbitMQ.Client.dll!RabbitMQ.Client.Framing.Impl.Connection.WriteFrame(RabbitMQ.Client.Impl.OutboundFrame f) Line 938
at C:\W ork\rabbitmq-dotnet-client\projects\RabbitMQ.Client\client\impl\Connection.cs(938)
RabbitMQ.Client.dll!RabbitMQ.Client.Framing.Impl.Connection.HeartbeatWriteTimerCallback(object state) Line 899
at C:\W ork\rabbitmq-dotnet-client\projects\RabbitMQ.Client\client\impl\Connection.cs(899)
_socket.Client is null on this line: _socket.Client.Poll(_writeableStateTimeoutMicroSeconds, SelectMode.SelectWrite);
My connection code looks like this:
var factory = new ConnectionFactory
{
HostName = _hostName,
UserName = _userName,
Password = _password,
RequestedHeartbeat = TimeSpan.FromSeconds(20),
AutomaticRecoveryEnabled = false,
ContinuationTimeout = TimeSpan.FromSeconds(20),
NetworkRecoveryInterval = TimeSpan.FromSeconds(10),
RequestedConnectionTimeout = TimeSpan.FromSeconds(20)
};
_connection = factory.CreateConnection();
_channel = _connection.CreateModel();
_channel.BasicQos(0, 200, false);
var consumer = new EventingBasicConsumer(_channel);
consumer.Received += ...;
consumer.Shutdown += ...;
consumer.Registered += ...
consumer.Unregistered += ...
consumer.ConsumerCancelled += OnConsumerCancelled;
_channel.BasicConsume(_queueName, false, consumer);
OnConsumerCancelled calls:
_channel?.Close();
_channel?.Dispose();
_connection?.Close(TimeSpan.FromMilliseconds(AbortTimeOutMs));
_connection?.Abort(TimeSpan.FromMilliseconds(AbortTimeOutMs));
... then tries to re-connect again using the above code
The NullReferenceException occurs some time during one of the (multiple) reconnection attempts.