Skip to content

Commit

Permalink
Address issue #1818 where MqttConnectionContext throws an error when …
Browse files Browse the repository at this point in the history
…passed a TcpConnection. (#1819)

* Address issue #1818 where MqttConnectionContext throws and error when passed a TcpConnection.

* Update ReleaseNotes.md

---------

Co-authored-by: Christian <[email protected]>
  • Loading branch information
CZEMacLeod and chkr1011 authored Aug 19, 2023
1 parent b1dc860 commit 2180f59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
7 changes: 5 additions & 2 deletions Source/MQTTnet.AspnetCore/MqttConnectionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit 2180f59

Please sign in to comment.