gausby / tortoise

A MQTT Client written in Elixir
Apache License 2.0
314 stars 54 forks source link

Incorrect handling of LWT/ graceful disconnect incorrect? #100

Open ebostijancic opened 5 years ago

ebostijancic commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

I just checked it with the following approach:

All tortoises are running as v0.9.4

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

dunyakirkali commented 3 years ago

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