From 7809dc3a565587eb119d86f489784d9181c36e01 Mon Sep 17 00:00:00 2001 From: "Cynthia Z E MacLeod (C3D)" Date: Sat, 19 Aug 2023 02:38:46 +0100 Subject: [PATCH 1/2] Address issue #1818 where MqttConnectionContext throws and error when passed a TcpConnection. --- Source/MQTTnet.AspnetCore/MqttConnectionContext.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs b/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs index 5804d8569..46d91412a 100644 --- a/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs +++ b/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs @@ -33,8 +33,11 @@ public MqttConnectionContext(MqttPacketFormatterAdapter packetFormatterAdapter, PacketFormatterAdapter = packetFormatterAdapter ?? throw new ArgumentNullException(nameof(packetFormatterAdapter)); _connection = connection ?? throw new ArgumentNullException(nameof(connection)); - _input = connection.Transport.Input; - _output = connection.Transport.Output; + if (!(_connection is TcpConnection tcp) || tcp.IsConnected) + { + _input = connection.Transport.Input; + _output = connection.Transport.Output; + } } public long BytesReceived { get; private set; } From 3d36cedaa17310ff8310ebca4d612bc89850962e Mon Sep 17 00:00:00 2001 From: Christian <6939810+chkr1011@users.noreply.github.com> Date: Sat, 19 Aug 2023 13:47:45 +0200 Subject: [PATCH 2/2] Update ReleaseNotes.md --- .github/workflows/ReleaseNotes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ReleaseNotes.md b/.github/workflows/ReleaseNotes.md index 12c9dfebf..f9abc621b 100644 --- a/.github/workflows/ReleaseNotes.md +++ b/.github/workflows/ReleaseNotes.md @@ -3,3 +3,4 @@ * [Server] Fixed _NullReferenceException_ in retained messages management (#1762, thanks to @logicaloud). * [Server] Exposed new option which allows disabling packet fragmentation (#1753). * [Server] Expired sessions will no longer be used when a client connects (#1756). +* [Server] Fixed an issue in connection handling for ASP.NET connections (#1819, thanks to @CZEMacLeod).