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
Currently an MqttClient is single use - meaning you need to dispose and create a new one to reconnect. It would be useful to be able to pull the connection up and down and have subscriptions re-sync without having to do these cleanups.
The text was updated successfully, but these errors were encountered:
How can I catch the fact that I have to re-connect. I'm currently wrapping nmqtt in a try-catch block but I cannot catch the fact that nmqtt is disconnected in order to do a dispose and reconnect (I've tested by shutting down the MQTT-broker)
{UnhandledExceptionController_Framework} -- -- 2013-11-27 08:55:30 -- Exception:
System.ObjectDisposedException
Level 1) Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.
StackTrace for Level 1:
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at Nmqtt.MqttConnection.Send(Byte[] message)
at Nmqtt.MqttConnection.Send(Stream message)
at Nmqtt.MqttConnectionHandler.SendMessage(MqttMessage message)
at Nmqtt.MqttConnectionKeepAlive.PingRequired(Object state)
at System.Threading._TimerCallback.TimerCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._TimerCallback.PerformTimerCallback(Object state)
Unfortunately there is no nice way of doing this at the moment.
The connection state is exposed on the MqttClient class and you can monitor that, but there is no pro-active notification. It’s a big hole I need to fill!
On Wednesday, 27 November 2013 at 08:26, Peter wrote:
How can I catch the fact that I have to re-connect. I'm currently wrapping nmqtt in a try-catch block but I cannot catch the fact that nmqtt is disconnected in order to do a dispose and reconnect (I've tested by shutting down the MQTT-broker)
{UnhandledExceptionController_Framework} -- -- 2013-11-27 08:55:30 -- Exception:
System.ObjectDisposedException
Level 1) Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.
StackTrace for Level 1:
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at Nmqtt.MqttConnection.Send(Byte[] message)
at Nmqtt.MqttConnection.Send(Stream message)
at Nmqtt.MqttConnectionHandler.SendMessage(MqttMessage message)
at Nmqtt.MqttConnectionKeepAlive.PingRequired(Object state)
at System.Threading.TimerCallback.TimerCallbackContext(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._TimerCallback.PerformTimerCallback(Object state)
Appreciate the help :-)
—
Reply to this email directly or view it on GitHub (#7 (comment)).
Currently an MqttClient is single use - meaning you need to dispose and create a new one to reconnect. It would be useful to be able to pull the connection up and down and have subscriptions re-sync without having to do these cleanups.
The text was updated successfully, but these errors were encountered: