RabbitMQ .Net client Error 541 System.Net.Sockets.SocketException (104): Connection reset by peer

Viewed 91

I am using the RabbitMq.Client Library v6.4.0 with the next IConnectionFactory:

var factory = new ConnectionFactory()
                {
                    HostName = brokerConfiguration.Server,
                    Port = brokerConfiguration.Port,
                    UserName = brokerConfiguration.User,
                    Password = brokerConfiguration.Password,
                    VirtualHost = brokerConfiguration.VirtualHost,
                    RequestedHeartbeat = TimeSpan.FromSeconds(20),
                    Ssl = new SslOption
                    {
                        Enabled = brokerConfiguration.EnableSsl,
                        AcceptablePolicyErrors = SslPolicyErrors.RemoteCertificateNameMismatch | SslPolicyErrors.RemoteCertificateChainErrors
                    }
                };
var connection = factory.CreateConnection();

The connection works correctly but each 60 minutes appears the next error in the connectionShutdown eventargs:

Connection Shutdown: Unexpected Exception, Code: 541, Initiator: Library, Cause: System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer.
 ---> System.Net.Sockets.SocketException (104): Connection reset by peer
   at System.Net.Sockets.NetworkStream.Read(Span`1 buffer)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Span`1 buffer)
   at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](TIOAdapter adapter)
   at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory`1 buffer)
   at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.BufferedStream.ReadByteSlow()
   at RabbitMQ.Client.Impl.InboundFrame.ReadFrom(Stream reader, Byte[] frameHeaderBuffer, ArrayPool`1 pool, UInt32 maxMessageSize)
   at RabbitMQ.Client.Framing.Impl.Connection.MainLoopIteration()
   at RabbitMQ.Client.Framing.Impl.Connection.MainLoop()

This problem appears in a docker container. How can I solve it? Thanks

0 Answers
Related