-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
how to make client send a disconnect packet? #1285
Comments
I have a app that have to publish to everyone that it are disconnecting. This is the way I do it:
I put this snippet in an disconnect function. Is this what you need? |
@jedwards1211 MQTT.js/test/abstract_client.js Lines 2825 to 2869 in 4bd3f3c
MQTT.js/test/abstract_client.js Lines 2828 to 2829 in 4bd3f3c
When the first client connection, set MQTT.js/test/abstract_client.js Lines 2852 to 2860 in 4bd3f3c
When you want to disconnect from the client side using DISCONNECT packet, you can call end() as follows: MQTT.js/test/abstract_client.js Lines 2840 to 2846 in 4bd3f3c
In this case, The important point is passing Alternative approach: |
The test case code set force option true when end() calling. MQTT.js/test/abstract_client.js Line 2840 in 4bd3f3c
In order to send DISCONNECT packet, you need to set force flag to false. Line 861 in d8be59e
Line 911 in d8be59e
Lines 1050 to 1074 in d8be59e
|
@redboltz Thanks for your examples. As I mentioned in #1286 (comment), I think it would be better not to store a clean flag on the stores and instead have the client tell the stores whether to discard state when the client is shutting down. It's counterintuitive that passing |
Ah, I just realized that you are the person who create the issue #1286. |
Right, I wasn't saying there's any incorrect behavior |
This is an automated message to let you know that this issue has If this issue is still important, you can simply comment with a Thank you for your contribution. |
This issue was automatically closed due to inactivity. |
In some tests I'm writing I need to make clients voluntarily disconnect, and reconnect later when I tell them to, with same clientId and session resending any QoS 1/2 messages.
Oddly it seems like there's no way to do this...
.end()
seems rather permanent and calling.reconnect()
afterwards doesn't seem to do anything.The text was updated successfully, but these errors were encountered: