Skip to content
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

Incorrect handling of LWT/ graceful disconnect incorrect? #100

Open
ebostijancic opened this issue Dec 31, 2018 · 3 comments
Open

Incorrect handling of LWT/ graceful disconnect incorrect? #100

ebostijancic opened this issue Dec 31, 2018 · 3 comments

Comments

@ebostijancic
Copy link

LWT is triggered on the broker even why the connection is terminated with the disconnect/1 method:

The Tortoise.Connection is added as a child to the DynamicSupervisor and after stopping all children with:
DynamicSupervisor.stop(Tasks, :shutdown)

The LWT is triggered on broker (emqx and mosquitto). Also when calling disconnect/1 I can see that LWT message is published.
:ok = Tortoise.Connection.disconnect("some_client_id")

@gausby
Copy link
Owner

gausby commented Dec 31, 2018

I just read up on what the MQTT 3.1.1 specification says about dispatching last will messages. The message should not get dispatched if the client send the disconnect message; I have to confirm that this is the case.

BTW: I am working on supporting MQTT 5; it changes how disconnect works. The user have options for specifying when the last will should get dispatched and such. I don't know when I will be done with the MQTT support.

@gausby
Copy link
Owner

gausby commented Dec 31, 2018

I just checked it with the following approach:

  • MQTT server (VerneMQ) running locally
  • One Tortoise running on a node connect to the local MQTT server and subscribe to "foo/bar"
  • Another Tortoise running in another node connect and announce a last will to the "foo/bar" topic; I set a trace on the send function on Tortoise.Transport.Tcp using Recon as such :recon_trace.calls({Tortoise.Transport.Tcp, :send, :_}, 100)

All tortoises are running as v0.9.4

  • When I ask the tortoise with the last will to disconnect the recon trace show that it correctly send the disconnect message to the broker. The other node does not receive the last will; as expected.
  • When I shut the "last will tortoise" down (by terminating the node or killing the process) the other node will receive the last will message on "foo/bar".

To me this seems to work as expected. Have I missed something in my testing?

@dunyakirkali
Copy link

Might be related but,

When I connect to Google IoT core using tortoise, if I kill tortoise I see in the Google logs) that the disconnect message throws an error.

However if I call Tortoise.Connection.disconnect("some_client_id") manually, then the disconnection happens correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants