-
Notifications
You must be signed in to change notification settings - Fork 884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client keeps on disconnecting and reconnecting #258
Comments
I cannot reproduce the problem.. Perhaps, you can explain the steps in more details.. I copied your code and changed it little bit as follows:
The test program:
The console shows that auto-reconnect was triggered and worked as expected:
|
Yours worked.No idea why mine didn't. |
it just appeared again in android too
logs
Goes on and on |
Are you using the same clientId in any other threads/process? |
Well..I am using device ID of phone as client Id so that's not possible.. It's only one device.And I tried changing client I'd and even broker... None helps |
The publisher is not on the same device, correct? |
Yea it's different. Can I do something here to see broker stats or something? |
Nvm.Its fixed. It was because i was running some ui thread code in 'onMessageArrived' . Though that should have raised exception |
I had a the issue of keeps on connecting and reconnecting on connection loss. I was doing like, if connectionLost() method in MqttCallback class is called I will call mqttClient.connect(). This will end in a loop. So instead of calling mqttClient.connect(), I called mqttClient.reconnect(); and the issue fixed. |
Hi everyone, On certain gateways, there are frequent connectionLost() callbacks (every few minutes). Inside the connectionLost() I simply raise a flag which is then read by the main thread application in order to perform a new MQTT connection. After the MQTT connection is performed succesfully, the connectionLost() is immediately called again.
Any suggestions? Many thanks in advance. |
Please fill out the form below before submitting, thank you!
Here's the class
Logs after calling subscribe() once
The text was updated successfully, but these errors were encountered: