瀏覽代碼

Merge pull request #838 from jimsch/connectErrors

Allow access to full packet on failed connect
release/3.x.x
Christian 5 年之前
committed by GitHub
父節點
當前提交
8ae318fd5c
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 3 個文件被更改,包括 7 次插入6 次删除
  1. +5
    -4
      Source/MQTTnet/Adapter/MqttConnectingFailedException.cs
  2. +1
    -1
      Source/MQTTnet/Client/MqttClient.cs
  3. +1
    -1
      Source/MQTTnet/Formatter/V5/MqttV500DataConverter.cs

+ 5
- 4
Source/MQTTnet/Adapter/MqttConnectingFailedException.cs 查看文件

@@ -5,12 +5,13 @@ namespace MQTTnet.Adapter
{
public class MqttConnectingFailedException : MqttCommunicationException
{
public MqttConnectingFailedException(MqttClientConnectResultCode resultCode)
: base($"Connecting with MQTT server failed ({resultCode.ToString()}).")
public MqttConnectingFailedException(MqttClientAuthenticateResult result)
: base($"Connecting with MQTT server failed ({result.ResultCode.ToString()}).")
{
ResultCode = resultCode;
Result = result;
}

public MqttClientConnectResultCode ResultCode { get; }
public MqttClientAuthenticateResult Result { get; }
public MqttClientConnectResultCode ResultCode => Result.ResultCode;
}
}

+ 1
- 1
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.");


+ 1
- 1
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,


Loading…
取消
儲存