-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Close received after close #1361
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
Comments
Great question. I dunno. Close received after a close suggests that the websocket connection was closed and then subsequently there was a call to close that same websocket connection despite it already being closed. Can you repro it repeatably? |
I encountered the same problem, I need to close the socket when reconnecting, but how to configure the code? |
I can't manually reproduce this situation, which typically occurs multiple times after MQTTJS has been running for a long time |
I have changed to the paho.mqtt.js library |
It's happen when you leave tab inactive for duration more than ~ 1 minutes |
Do you mean web sleep is the cause? |
Sorry, din not understand. |
@amnonbb can you provide a reproducible code snippet please. will attempt repro and debug. |
I discovered that if i connect with keepalive option = 1 or 2 sec, the error above fire after ~ 5 seconds on inactive tab |
@amnonbb and you're just starting a client, connecting via WS, and sending messages? do you have a code snippet i can paste and run? |
thanks! |
same here. |
I have the same problem |
same here |
Has been troubled by this issue. come on! |
When you are listening for a If you receive another message during the closing process, it will trigger a Change to |
MQTT 5.0.0 BETA is now available! Try it out and give us feedback: |
This could be related to #1257 and may be fixed in latest version. Could someone check this? |
This still alive. Update to v5.0.1 |
npoe, the problem still exists, it's due to the browser tab throttling, and it's not uncommon for setInterval and setTimeout to lose precision in certain situations (e.g. when a tab is inactive) The solution I can think of is to create highly accurate timers via Web Wroker (since Web Workers run in a thread separate from the main thread, they are not affected by the main thread and can accurately trigger timer events at any time, even when the main thread's event loop is blocked or the browser tab is inactive). Of course this comes at the expense of mqtt's compatibility, making it unsupported in Internet Explorer 9 and below. |
This issue still occurs in version 5.0.3 |
May be related to #1257 |
May get fixed by #1753 , available starting from version 5.3.2 |
great ! MqttClient.prototype.end = function () {...} use end(ture) is very useful |
Why is this error always reported when running for a long time: WebSocket connection to 'ws://xxx/mqtt' failed: Close received after close

version: 4.2.8
browser: Microsoft Edge 95.0.1020.53
The text was updated successfully, but these errors were encountered: