paho.mqtt.javascript icon indicating copy to clipboard operation
paho.mqtt.javascript copied to clipboard

Reconnect on mobile devices

Open apapacy opened this issue 5 years ago • 4 comments

I am using paho-mqtt with react-native on mobile devices. After the application enters the background state, the connection is broken. When the application resumes, the reconnect timeout is at a minimum value 1 seconds. But, missed messages begin to arrive after 60 second as keepAliveInterval default value.

Desired behavior. After determining that the application has left the background or sleep state, immediately connect to the server and receive all pending messages.

apapacy avatar May 26 '19 06:05 apapacy

@apapacy Where did you land on this? I am not using react native, but I am using react and am having a similar issue where if the screen is locked from a mobile device, the client's connection is severed and takes a up to a full minute to reconnect. If this is actually tied to the keepAliveInterval, would setting that lower actually help with reconnect time?

Also, digressing a bit, I have noticed that the Python version has a method for customizing the reconnect delay yet I cannot seem to find anything similar in the docs for Javascript. It would be nice to have this feature for JS users as well.

corey-mitchell avatar Sep 23 '19 23:09 corey-mitchell

it depends on the value of the parameter keepAliveInterval and in my opinion controlled by server.

apapacy avatar Sep 28 '19 15:09 apapacy

Excuse me @apapacy! How can u use paho-mqtt in react-native

tuan511 avatar Feb 08 '20 17:02 tuan511

Excuse me @apapacy! How can u use paho-mqtt in react-native

I used this Tutorial

However I'm getting a problem when I'm releasing my apk (https://stackoverflow.com/questions/60895132/app-works-in-android-and-ios-simulator-but-not-after-release)

marmundo avatar Mar 27 '20 23:03 marmundo