Open naymore opened 3 months ago
Also in the WIKI the "event based approach" is recommended. Just saying... https://github.com/dotnet/MQTTnet/wiki/Client#reconnecting
Also in the WIKI the "event based approach" is recommended. Just saying... https://github.com/dotnet/MQTTnet/wiki/Client#reconnecting
The wiki is for the old version (3.* and below only). Just saying. The samples are the way to go.
This is what your best practice sample says:
I figured the ConnectAsync() method will always fail with "you cannot connect while already connected". So I need to wait for the Client to realize the connection has been dropped before I can reconnect.
There are two solutions to this.
Check for client.IsConnected - but that kind of defeats the purpose of the whole TryPing thing. If I am not connected I don't need to ping because I know the ping will fail. If I am connected and the ping fails I need to wait for the client to realize this too before I can make any reconnection attempts.
If the ping fails --> disconnect gracefully and start reconnecting immediately.
My preferred option would be this is handled by the library internally ;-) So I'll start looking at the ManagedClient as well.
Which project is your question related to?