MQTT communication exception while receiving packets
See original GitHub issueI use the MQTTnet client to connect to aws iot through a presigned url, it works, however, every about 100 seconds (it is pretty accurate every time) it will get disconnected. i am not sure why. here is the log i got:
>> [2018-01-19T15:59:07.0172770-05:00] [10] [MqttClient] [Verbose]: Trying to connect with server.
>> [2018-01-19T15:59:07.0202781-05:00] [10] [MqttChannelAdapter] [Verbose]: Connecting [Timeout=00:00:30]
>> [2018-01-19T15:59:07.1783819-05:00] [11] [MqttClient] [Verbose]: Connection with server established.
>> [2018-01-19T15:59:07.1853863-05:00] [7] [MqttClient] [Info]: Start receiving packets.
>> [2018-01-19T15:59:07.3435203-05:00] [5] [MqttChannelAdapter] [Verbose]: TX >>> Connect: [ClientId=360d99a6fe41b3c1c6a095993b7ae9b6d2ca979c9b9cc690de1d03a7fe2f8e51] [Username=] [Password=] [KeepAlivePeriod=10] [CleanSession=True] [Timeout=00:00:30]
>> [2018-01-19T15:59:07.4546491-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< ConnAck: [ConnectReturnCode=ConnectionAccepted] [IsSessionPresent=False]
>> [2018-01-19T15:59:07.4696600-05:00] [5] [MqttClient] [Info]: Received <<< ConnAck: [ConnectReturnCode=ConnectionAccepted] [IsSessionPresent=False]
>> [2018-01-19T15:59:07.4726629-05:00] [5] [MqttClient] [Verbose]: MQTT connection with server established.
>> [2018-01-19T15:59:07.4886676-05:00] [9] [MqttClient] [Info]: Start sending keep alive packets.
>> [2018-01-19T15:59:07.4896734-05:00] [9] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T15:59:07.4966735-05:00] [5] [MqttChannelAdapter] [Verbose]: TX >>> Subscribe: [PacketIdentifier=1] [TopicFilters=57e581b25854ac000ff6f3ef@AtLeastOnce,59272c7e80e5cf82a30d39fb@AtLeastOnce,57fcd4575730e4000f9ba85f@AtLeastOnce] [Timeout=00:00:30]
>> [2018-01-19T15:59:07.5086791-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T15:59:07.5096801-05:00] [9] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T15:59:07.5527116-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< SubAck: [PacketIdentifier=1] [SubscribeReturnCodes=SuccessMaximumQoS1,SuccessMaximumQoS1,SuccessMaximumQoS1]
>> [2018-01-19T15:59:07.5527116-05:00] [12] [MqttClient] [Info]: Received <<< SubAck: [PacketIdentifier=1] [SubscribeReturnCodes=SuccessMaximumQoS1,SuccessMaximumQoS1,SuccessMaximumQoS1]
>> [2018-01-19T15:59:17.5244169-05:00] [5] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T15:59:17.5444309-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T15:59:17.5454313-05:00] [5] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T15:59:27.5646272-05:00] [5] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T15:59:27.5836342-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T15:59:27.5836342-05:00] [5] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T15:59:37.5868786-05:00] [9] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T15:59:37.6078826-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T15:59:37.6078826-05:00] [12] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T15:59:40.6239881-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< Publish: [Topic=57fcd4575730e4000f9ba85f] [Payload.Length=512] [QoSLevel=AtLeastOnce] [Dup=False] [Retain=False] [PacketIdentifier=1]
>> [2018-01-19T15:59:40.6239881-05:00] [9] [MqttClient] [Info]: Received <<< Publish: [Topic=57fcd4575730e4000f9ba85f] [Payload.Length=512] [QoSLevel=AtLeastOnce] [Dup=False] [Retain=False] [PacketIdentifier=1]
>> [2018-01-19T15:59:40.9493656-05:00] [9] [MqttChannelAdapter] [Verbose]: TX >>> PubAck [Timeout=00:00:30]
>> [2018-01-19T15:59:47.6221570-05:00] [9] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T15:59:47.6482058-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T15:59:47.6491995-05:00] [9] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T15:59:57.6662408-05:00] [9] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T15:59:57.6872503-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T15:59:57.6892564-05:00] [9] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T16:00:07.7111522-05:00] [9] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T16:00:07.7321702-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T16:00:07.7331669-05:00] [9] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T16:00:17.7528845-05:00] [12] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T16:00:17.7728972-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T16:00:17.7748992-05:00] [9] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T16:00:27.7791319-05:00] [9] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T16:00:27.8011393-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T16:00:27.8021397-05:00] [9] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T16:00:37.8198474-05:00] [12] [MqttChannelAdapter] [Verbose]: TX >>> PingReq [Timeout=00:00:30]
>> [2018-01-19T16:00:37.8388580-05:00] [7] [MqttChannelAdapter] [Verbose]: RX <<< PingResp
>> [2018-01-19T16:00:37.8388580-05:00] [11] [MqttClient] [Info]: Received <<< PingResp
>> [2018-01-19T16:00:47.4215941-05:00] [7] [MqttClient] [Warning]: MQTT communication exception while receiving packets.
MQTTnet.Exceptions.MqttCommunicationException: The remote party closed the WebSocket connection without completing the close handshake. ---> System.Net.WebSockets.WebSocketException: The remote party closed the WebSocket connection without completing the close handshake. ---> System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'SslStream'.
at System.Net.Security.SslState.CheckThrow(Boolean authSuccessCheck, Boolean shutdownCheck)
at System.Net.Security.SslState.get_SecureStream()
at System.Net.TlsStream.EndRead(IAsyncResult asyncResult)
at System.Net.PooledStream.EndRead(IAsyncResult asyncResult)
at System.IO.Stream.<>c.<BeginEndReadAsync>b__43_1(Stream stream, IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Net.WebSockets.WebSocketConnectionStream.<ReadAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Net.WebSockets.WebSocketBase.WebSocketOperation.<Process>d__19.MoveNext()
--- End of inner exception stack trace ---
at System.Net.WebSockets.WebSocketBase.WebSocketOperation.<Process>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Net.WebSockets.WebSocketBase.<ReceiveAsyncCore>d__45.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MQTTnet.Implementations.WebSocketStream.<FetchChunkAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MQTTnet.Implementations.WebSocketStream.<ReadAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MQTTnet.Implementations.WebSocketStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Stream.ReadByte()
at MQTTnet.Serializer.MqttPacketReader.ReadHeaderFromSource(Stream stream, CancellationToken cancellationToken)
at MQTTnet.Adapter.MqttChannelAdapter.<ReceiveAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MQTTnet.Adapter.MqttChannelAdapter.<>c__DisplayClass12_0.<<ReceivePacketAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MQTTnet.Adapter.MqttChannelAdapter.<ExecuteAndWrapExceptionAsync>d__14.MoveNext()
--- End of inner exception stack trace ---
at MQTTnet.Adapter.MqttChannelAdapter.<ExecuteAndWrapExceptionAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MQTTnet.Adapter.MqttChannelAdapter.<ReceivePacketAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MQTTnet.Client.MqttClient.<ReceivePacketsAsync>d__40.MoveNext()
>> [2018-01-19T16:00:47.4676255-05:00] [7] [MqttClient] [Info]: Stopped sending keep alive packets.
>> [2018-01-19T16:00:47.4686240-05:00] [7] [MqttChannelAdapter] [Verbose]: Disconnecting [Timeout=00:00:30]
>> [2018-01-19T16:00:47.4716251-05:00] [7] [MqttClient] [Info]: Disconnected from adapter.
>> [2018-01-19T16:00:47.4716251-05:00] [7] [MqttClient] [Info]: Disconnected.
>> [2018-01-19T16:00:47.4776303-05:00] [7] [MqttClient] [Info]: Stopped receiving packets.
I am not sure if this is a issue with aws or not, but just can not find the cause.
Issue Analytics
- State:
- Created 6 years ago
- Comments:38 (1 by maintainers)
Top Results From Across the Web
MQTT communication exception while receiving packets
I use the MQTTnet client to connect to aws iot through a presigned url, it works, however, every about 100 seconds (it is...
Read more >Resolving problem: MQTT client does not connect
Check that the telemetry (MQXR) service and the queue manager are running normally. Use netstat to check that the socket address is not...
Read more >Topic: Mqtt communication error
Hi everyone, I've installed 2 mqtt communication channels on Rapidscada on Ubuntu, One mqtt channel works well, but another don't work.
Read more >MQTT Client Error Codes
Error code (Decimal) Error code (Hex) Meaning
0 0x0 No Error
1 0x1 Connection Refused: Unacceptable protocol version
10 0xa Timeout waiting for SUBACK
Read more >MQTT Reason Code Introduction and Quick Reference - EMQ
Reason Code Name Packets
0x00 Normal disconnection DISCONNECT
0x00 Granted QoS 0 SUBACK
0x01 Granted QoS 1 SUBACK
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I created an issue on the .NET Framework issue tracker, https://developercommunity.visualstudio.com/content/problem/629916/websocket-times-out-after-100-seconds.html
I close this ticket because I assume it is fixed.