Send DISCONNECT packets to MQTT5 clients only (#1506)

This commit is contained in:
logicaloud
2022-09-13 09:00:21 +02:00
committed by GitHub
parent 3ab095a568
commit 37e60c73ae
3 changed files with 102 additions and 2 deletions
+3 -1
View File
@@ -147,7 +147,9 @@ namespace MQTTnet.Server
{
IsRunning = false;
if (reason == MqttDisconnectReasonCode.SessionTakenOver || reason == MqttDisconnectReasonCode.KeepAliveTimeout)
// Potentially send disconnect reason to MQTT 5 clients
if (ChannelAdapter.PacketFormatterAdapter.ProtocolVersion == MqttProtocolVersion.V500 && reason != MqttDisconnectReasonCode.NormalDisconnection)
{
// Is is very important to send the DISCONNECT packet here BEFORE cancelling the
// token because the entire connection is closed (disposed) as soon as the cancellation