MQTTnet: cannot read data from the transport connection: the remote host forcibly closed an existing connection

MqttServer.MqttClientSessionsManager.MqttClientSession
MQTTnet.Exceptions.MqttCommunicationException: was unable to read data from the transport connection: the remote host forced an existing connection to be closed. -> System.IO.IOException: cannot read data from the transport connection: the remote host forcibly closed an existing connection. -> System.Net.Sockets.SocketException: remote host forced an existing connection to be closed.
at the end of System.Net.Sockets.Socket.EndReceive (IAsyncResult asyncResult)
at the end of the System.Net.Sockets.NetworkStream.EndRead (IAsyncResult asyncResult)
-Internal exception stack trace-
at System.Net.Sockets.NetworkStream.EndRead (IAsyncResult asyncResult)
at System.IO.Stream. < > c. < BeginEndReadAsync > bounded exception 431( Stream stream, IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory 1.FromAsyncTrimPromise 1.Complete (TInstance thisRef, function `3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization)
-the end of the stack trace in the last location where the exception was thrown-
in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task)
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)
in MQTTnet.Serializer.MqttPacketReader. < ReadFixedHeaderAsync > d__0.MoveNext ()
-the end of the stack trace in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task)
at the end of the stack trace in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)
in MQTTnet.Adapter.MqttChannelAdapter. < ReceiveAsync > d__24.MoveNext ()
-the last location where the exception was thrown-
in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task)
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)
in MQTTnet.Adapter.MqttChannelAdapter. < ReceivePacketAsync > d__23.MoveNext ()
-Internal exception stack End of trace-
in MQTTnet.Adapter.MqttChannelAdapter.WrapException (Exception exception)
in MQTTnet.Adapter.MqttChannelAdapter. < ReceivePacketAsync > d__23.MoveNext ()
-the end of the stack trace-
in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task task)
in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task task)
in MQTTnet.Server.MqttClientSession. < RunAsync > d__17.MoveNext ()-sharp-sharp-sharp description

the environmental background of the problems and what methods you have tried

this is an error reported by the server. An attempt was made to solve it on the client, but there was no result

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Oct.14,2021

encountered the same problem.

if that's what you wrote:

var options = new MqttClientOptionsBuilder()
    .WithClientId("Client1")
    .WithTcpServer("broker.hivemq.com")
    .WithCredentials("bud", "%spencer%")
    .WithTls()
    .WithCleanSession()
    .Build();
    
    
          
      .WithCredentials("bud", "%spencer%")
      .WithTls()
    
Menu