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
[Bug]: Error: Keepalive timeout, js engine: hermes - React Native #1853
Comments
@abdelhameedhamdy I need debug logs, seems that happens because the broker doesn't respond to a ping in the keepliave timeout you specified on settings (5 minutes). Try to use a lower keepalive like 10 seconds and enable logs and attach them here |
keepalive set to 10 sec, and logs as following :
appeared in the log |
@abdelhameedhamdy Could yuou also try using 5.3.4? Is your log truncated? I don't see the cleanup part after the keepalive timeout error |
Just extracted a sample of repeated pattern. If switching to 5.3.4, RN App won't run, as it needs the last fixes like buffer packages and other url blob issues appears in 5.3.4, in addition to |
Sorry I meant 5.5.4 |
Your logs makes no sense to me as that error is emitted right before closing the client and I see no mention to the cleanUp Lines 2128 to 2130 in 6f3109a
|
Already on last release 5.5.4, and the log was based on it as well. |
@abdelhameedhamdy Do you have an |
Yes, I have one, and this error is not caught in it when it comes, I was trying to handle it. |
|
And this another log with keepalive set to 5 min
with the |
Try with the coming version 5.5.5 |
Tested with 5.5.5, and same error appears, logs
wondering, why it's uncaught in client.on('error') ! |
Another log, with same error repeated.
|
Seems your keepalive is 10s not 5 minutes, could you attach full logs from startup? |
Yes, it is set to 10 sec not 5, the last log is a full one from starting a connection with mqtt |
My case scenario, mobile app opens a connection to mqtt, then when app bacgrounded, it reconnects again with the same mqtt options mentioned before, (keealive set to 10 sec), then the keepalive timeout appears, attached extra logs for the whole case:
|
Logs, after app came to foreground, with keepalive timeouts,
|
As I said above everything seems correct from mqtt side, the keepalive timeout error is triggered because no packet is received in the keepalive time, the only very strange thing is that the keepalive timeout doesn't trigger the close of client. You should debug this on your side if possible by putting breakpoints on mqttjs code and see where it breaks. Expecially in this line: Lines 2136 to 2137 in 0c72b5a
The error here is it is not calling cleanUp |
Could you show me the code you have in client.on('error' ) listener? |
|
My feel is that you do something there that stops the event loop and that's the reason why the cleanUp isn't called |
So, because of the _cleanUp() is not called, the keepalive timeout error is uncaught ! |
Nope, I didn't meant that. The keepalive timeout is uncaught because you may be doing something strange in the error listener... |
Ok, I think I caught it, when re-connecting with the same clientid which is intended, I was not ending the connection manually as I was counting on that the connection will be auto-closed and connect, now I enforce the client to end before reconnecting, and no error appears now. |
Thank you @robertsLando, the connection is stable now. |
I'm not sure I got what you meant here but generally the client should handle it's connection/reconnection itself without the need you manually end it or else but glad you fixed it |
It is two clients with same connection params, one for foreground and the the other for background mode, so they shares the same clientid when connecting (i.e. only one client at a time, not at the same time), and each one force the other to close automatically when trying to connect. |
MQTTjs Version
5.5.3
Broker
flespi
Environment
NodeJS
Description
In React Native (Expo) , after some random time (few minutes), the following error appears
Error: Keepalive timeout, js engine: hermes
mqttOptions params :
Minimal Reproduction
Connecting to Flespi broker sample:
https://flespi.com/mqtt-broker#client
Debug logs
ERROR Error: Keepalive timeout, js engine: hermes
The text was updated successfully, but these errors were encountered: