Fix issue when stopping server

This commit is contained in:
Christian Kratky
2017-07-15 18:36:33 +02:00
parent 2193281c6a
commit 886b2d6b42
4 changed files with 9 additions and 3 deletions
@@ -63,6 +63,7 @@ namespace MQTTnet.Implementations
{
_isRunning = false;
_cancellationTokenSource?.Cancel(false);
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = null;
@@ -88,7 +89,7 @@ namespace MQTTnet.Implementations
var clientAdapter = new MqttChannelCommunicationAdapter(new MqttTcpChannel(clientSocket, null), new DefaultMqttV311PacketSerializer());
ClientConnected?.Invoke(this, new MqttClientConnectedEventArgs(clientSocket.RemoteEndPoint.ToString(), clientAdapter));
}
catch (Exception exception)
catch (Exception exception) when (!(exception is ObjectDisposedException))
{
MqttTrace.Error(nameof(MqttServerAdapter), exception, "Error while acceping connection at default endpoint.");
}