Open IliasP91 opened 2 years ago
All subscriptions are managed across server connections. There is no need to subscribe manually after the connection with the server is lost.
_emitter.Connected += async (s, e) =>
{
await _emitter.Subscribe(.....)
}
ah i see so its intentionally designed like this to ignore the manage client's internal queue if recover is set to false. shouldnt the param also be named "queue" like the one in the Publish method though?
awesome it works just fine with setting the Subscribe recover param to true. thanks!
in fact scratch that, if recover is set to true in the subscribe method right after connect, it still doesnt handle messages published later on not sure why though
publish queue
uses feature
All MQTT application messages are added to an internal queue and processed once the server is available.
subs recover
uses feature
All subscriptions are managed across server connections. There is no need to subscribe manually after the connection with the server is lost.
But there is no gurantee that the listener can receive all messages. You can use retain
option to keep latested message in mqtt protocol
alright so the most "reliable" way would be to set subscribers only after the connected event has ben fired right? cool ill do some more testing later on but it should be alright. at least my main issue of not being able to connect with tls from a c# client is now working fine
Do we really need to call the internal client directly in places like the following?
in my case if I do a subscription or publish right after the connect await returns then its throwing an exception
where in the MQTTnet examples this is running perfectly fine(tried that snippet in my code as well and its ok) https://github.com/dotnet/MQTTnet/blob/master/Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs
its not a big deal as the subscriptions etc could be added in a callback on the Connected event but if this could work then it makes the code flow a bit better i think