Closed erroot closed 3 months ago
Sorry - I only understand English.
Only moving from disconnected to connecting was a deliberate choice (if the status is not disconnected then something is still running so connecting is not a valid operation). However it's possible there is a bug/logic error somewhere, unfortunately I'll need more information (ideally an example that replicates the issue) in order to understand the issue you are facing. Note that with AutoReconnect operational (the default) there is no need for you to call Connect
again.
Sorry - I only understand English.
Only moving from disconnected to connecting was a deliberate choice (if the status is not disconnected then something is still running so connecting is not a valid operation). However it's possible there is a bug/logic error somewhere, unfortunately I'll need more information (ideally an example that replicates the issue) in order to understand the issue you are facing. Note that with AutoReconnect operational (the default) there is no need for you to call
Connect
again.
I have a similar problem.
IsConnected() is false,but AutoReconnect is not working。
Logs of ConnectionLostHandler,ReconnectHandler,ConnectionAttemptHandler were not recorded. I call Disconnect,sleep 2 seconds,call Connect,response is ’status can only transition to connecting from disconnected‘。 Kill the program,restart it ok.
Check the status of mosquitto service is running normally.
@Zhseek
IsConnected() is false,but AutoReconnect is not working
IsConnected()
does not tell you whether there is a connection to the broker, it's more of an indicator as to whether there is a current connection or the client is attempting to reestablish one (so if that's returning false then either the reconnect settings are false or Disconnect
has been called).
call Disconnect,sleep 2 seconds,call Connect,response is ’status can only transition to connecting from disconnected
Two seconds might, or might not, be long enough - it depends on what handlers are running.
Unfortunately without an example that reproduces the issue, or, at minimum, logs, it's difficult to trace this kind of issue. The more info you provide the more likely it is that someone will put some effort into fixing it (I don't use this client much, so will only look into this myself if I can easily replicate the issue).
I'm going to close this because I can't really take any action without more information.
这样写的重连机制有问题:MQTT 连接失败: status can only transition to connecting from disconnected 库内部认为状态不对,但是进程重启是可以重连的