You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a client connection using MqttClientConnectionContextFactory in an AspNetCore project, an error is thrown and the client does not connect.
MqttClientConnectionContextFactory passes a TcpConnection object to MqttConnectionContext for the ConnectionContext parameter in the constructor.
The constructor tries to store the connection.Transport.Input and connection.Transport.Output into local fields, however connection.Transport is null because StartAsync on TcpConnection has not yet been called.
…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]>
Describe the bug
When creating a client connection using
MqttClientConnectionContextFactory
in an AspNetCore project, an error is thrown and the client does not connect.MqttClientConnectionContextFactory passes a
TcpConnection
object toMqttConnectionContext
for theConnectionContext
parameter in the constructor.The constructor tries to store the
connection.Transport.Input
andconnection.Transport.Output
into local fields, howeverconnection.Transport
is null becauseStartAsync
onTcpConnection
has not yet been called.MQTTnet/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs
Lines 36 to 37 in b1dc860
There is code in
ConnectAsync
that is meant to address this, but the code never gets there since the constructor throws an NRE.MQTTnet/Source/MQTTnet.AspnetCore/MqttConnectionContext.cs
Lines 109 to 118 in b1dc860
Which component is your bug related to?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should not throw and error. The transport properties should be initialized in only one place under ConnectAsync.
The text was updated successfully, but these errors were encountered: