From d4088420cf88382b4486be8ce8516ee34931c8b2 Mon Sep 17 00:00:00 2001 From: Jim Schaad Date: Tue, 31 Dec 2019 14:33:31 -0800 Subject: [PATCH 1/4] Return correct set of user properties Return the response not the request set of user properties --- Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs b/Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs index 42d3241..886b937 100644 --- a/Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs +++ b/Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs @@ -139,7 +139,7 @@ namespace MQTTnet.Formatter.V5 ReasonCode = connectionValidatorContext.ReasonCode, Properties = new MqttConnAckPacketProperties { - UserProperties = connectionValidatorContext.UserProperties, + UserProperties = connectionValidatorContext.ResponseUserProperties, AuthenticationMethod = connectionValidatorContext.AuthenticationMethod, AuthenticationData = connectionValidatorContext.ResponseAuthenticationData, AssignedClientIdentifier = connectionValidatorContext.AssignedClientIdentifier, From 9c378fb08859ddf05bbdfc06a39983ae0c352cb5 Mon Sep 17 00:00:00 2001 From: Jim Schaad Date: Tue, 31 Dec 2019 14:44:25 -0800 Subject: [PATCH 2/4] Provide the full ACK on a connection failure There are some systems that return information on a failed exception and thus the client wants access to the full set of ACK information. Specifically the user properties. --- Source/MQTTnet/Adapter/MqttConnectingFailedException.cs | 7 ++++--- Source/MQTTnet/Client/MqttClient.cs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs b/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs index 44d50ec..158cc9a 100644 --- a/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs +++ b/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs @@ -5,12 +5,13 @@ namespace MQTTnet.Adapter { public class MqttConnectingFailedException : MqttCommunicationException { - public MqttConnectingFailedException(MqttClientConnectResultCode resultCode) + public MqttConnectingFailedException(MqttClientAuthenticateResult resultCode) : base($"Connecting with MQTT server failed ({resultCode.ToString()}).") { - ResultCode = resultCode; + Result = resultCode; } - public MqttClientConnectResultCode ResultCode { get; } + public MqttClientAuthenticateResult Result { get; } + public MqttClientConnectResultCode ResultCode => Result.ResultCode; } } diff --git a/Source/MQTTnet/Client/MqttClient.cs b/Source/MQTTnet/Client/MqttClient.cs index c9ef061..4d8269d 100644 --- a/Source/MQTTnet/Client/MqttClient.cs +++ b/Source/MQTTnet/Client/MqttClient.cs @@ -255,7 +255,7 @@ namespace MQTTnet.Client if (result.ResultCode != MqttClientConnectResultCode.Success) { - throw new MqttConnectingFailedException(result.ResultCode); + throw new MqttConnectingFailedException(result); } _logger.Verbose("Authenticated MQTT connection with server established."); From b1559a8fa55aea86d4704a23961c143f10b4a77d Mon Sep 17 00:00:00 2001 From: Jim Schaad Date: Wed, 8 Jan 2020 11:11:41 -0800 Subject: [PATCH 3/4] Correct to print right result Lost a change while moving from my developement branch to here. --- Source/MQTTnet/Adapter/MqttConnectingFailedException.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs b/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs index 158cc9a..9a14999 100644 --- a/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs +++ b/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs @@ -6,7 +6,7 @@ namespace MQTTnet.Adapter public class MqttConnectingFailedException : MqttCommunicationException { public MqttConnectingFailedException(MqttClientAuthenticateResult resultCode) - : base($"Connecting with MQTT server failed ({resultCode.ToString()}).") + : base($"Connecting with MQTT server failed ({resultCode.ResultCode.ToString()}).") { Result = resultCode; } From 7dde2f1f4c8e5f2b06d67a362752bb529a816b68 Mon Sep 17 00:00:00 2001 From: Jim Schaad Date: Sun, 12 Jan 2020 12:31:09 -0800 Subject: [PATCH 4/4] Change variable name per review request Change the name of the variable from requestCode to request --- Source/MQTTnet/Adapter/MqttConnectingFailedException.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs b/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs index 9a14999..ab49d93 100644 --- a/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs +++ b/Source/MQTTnet/Adapter/MqttConnectingFailedException.cs @@ -5,10 +5,10 @@ namespace MQTTnet.Adapter { public class MqttConnectingFailedException : MqttCommunicationException { - public MqttConnectingFailedException(MqttClientAuthenticateResult resultCode) - : base($"Connecting with MQTT server failed ({resultCode.ResultCode.ToString()}).") + public MqttConnectingFailedException(MqttClientAuthenticateResult result) + : base($"Connecting with MQTT server failed ({result.ResultCode.ToString()}).") { - Result = resultCode; + Result = result; } public MqttClientAuthenticateResult Result { get; }