diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec
index 96389fa2..25c31fb5 100644
--- a/Build/MQTTnet.nuspec
+++ b/Build/MQTTnet.nuspec
@@ -27,8 +27,10 @@
* [Server] Keep alive checking is now suspended while large packages are being received (and thus the client is connected). Keep alive checking continues after a large packet is received completely.
* [Server] Rewritten the _ConnectedClients_ API and added new features for disconnecting and Endpoint information (IP etc.).
* [Server] Added settings for disabling persistent sessions and defining a max pending messages queue size per session.
+* [Server] Persistent sessions are disabled by default (BREAKING CHANGE!).
* [Server] Added a new interceptor which is invoked before a new message is added to the client queue.
* [Server] Added support for Linux servers by dividing IPv4 and IPv6 support and adding new options (BREAKING CHANGE!).
+* [Server] Gracefully closed connections are no longer reported as warnings.
Copyright Christian Kratky 2016-2018
MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin
diff --git a/Source/MQTTnet/Exceptions/MqttCommunicationClosedGracefullyException.cs b/Source/MQTTnet/Exceptions/MqttCommunicationClosedGracefullyException.cs
new file mode 100644
index 00000000..21a66b90
--- /dev/null
+++ b/Source/MQTTnet/Exceptions/MqttCommunicationClosedGracefullyException.cs
@@ -0,0 +1,6 @@
+namespace MQTTnet.Exceptions
+{
+ public class MqttCommunicationClosedGracefullyException : MqttCommunicationException
+ {
+ }
+}
diff --git a/Source/MQTTnet/Implementations/MqttTcpServerListener.cs b/Source/MQTTnet/Implementations/MqttTcpServerListener.cs
index 4bf2b081..fccd77f3 100644
--- a/Source/MQTTnet/Implementations/MqttTcpServerListener.cs
+++ b/Source/MQTTnet/Implementations/MqttTcpServerListener.cs
@@ -76,6 +76,8 @@ namespace MQTTnet.Implementations
await sslStream.AuthenticateAsServerAsync(_tlsCertificate, false, SslProtocols.Tls12, false).ConfigureAwait(false);
}
+ _logger.Verbose($"Client '{clientSocket.RemoteEndPoint}' accepted by TCP listener '{_socket.LocalEndPoint}, {_addressFamily}'.");
+
var clientAdapter = new MqttChannelAdapter(new MqttTcpChannel(clientSocket, null), new MqttPacketSerializer(), _logger);
ClientAccepted?.Invoke(this, new MqttServerAdapterClientAcceptedEventArgs(clientAdapter));
}
diff --git a/Source/MQTTnet/Internal/ExceptionHelper.cs b/Source/MQTTnet/Internal/ExceptionHelper.cs
index 2b504511..f3cadc91 100644
--- a/Source/MQTTnet/Internal/ExceptionHelper.cs
+++ b/Source/MQTTnet/Internal/ExceptionHelper.cs
@@ -6,7 +6,7 @@ namespace MQTTnet.Internal
{
public static void ThrowGracefulSocketClose()
{
- throw new MqttCommunicationException("Connection gracefully closed from the remote party.");
+ throw new MqttCommunicationClosedGracefullyException();
}
}
}
diff --git a/Source/MQTTnet/Server/MqttClientSession.cs b/Source/MQTTnet/Server/MqttClientSession.cs
index cb1043be..ed029432 100644
--- a/Source/MQTTnet/Server/MqttClientSession.cs
+++ b/Source/MQTTnet/Server/MqttClientSession.cs
@@ -100,7 +100,14 @@ namespace MQTTnet.Server
{
if (exception is MqttCommunicationException)
{
- _logger.Warning(exception, "Client '{0}': Communication exception while receiving client packets.", ClientId);
+ if (exception is MqttCommunicationClosedGracefullyException)
+ {
+ _logger.Verbose("Client '{0}': Connection closed gracefully.", ClientId); ;
+ }
+ else
+ {
+ _logger.Warning(exception, "Client '{0}': Communication exception while receiving client packets.", ClientId);
+ }
}
else
{
diff --git a/Tests/MQTTnet.TestApp.NetCore/ClientTest.cs b/Tests/MQTTnet.TestApp.NetCore/ClientTest.cs
index b943bc3f..98e7f0b1 100644
--- a/Tests/MQTTnet.TestApp.NetCore/ClientTest.cs
+++ b/Tests/MQTTnet.TestApp.NetCore/ClientTest.cs
@@ -20,7 +20,7 @@ namespace MQTTnet.TestApp.NetCore
{
ChannelOptions = new MqttClientTcpOptions
{
- Server = "localhost"
+ Server = "127.0.0.1"
}
};