Intermittent connection dropout & LWT issue #849

Open
arvindr21 opened this Issue Jan 6, 2017 · 1 comment

Projects

None yet

1 participant

@arvindr21

Environment

  • OS: Ubuntu 14.04
  • Erlang/OTP:
  • EMQ: 2.0

Description

We are using https://github.com/tuanpmt/esp_mqtt to connect to EMQTT broker. We have set a connection keepalive to 10 seconds. Based on this PR : tuanpmt/esp_mqtt#118 by @vowstar the client is sending the server a ping every 5 seconds and it seems to work fine. I have traced the same using

$ ./bin/emqttd_ctl trace client "client_1" "trace_client_1.log" #turn on tracing for a client
$ tail -f trace_client_1.log #tail the logs to see what is happening..

04:34:39.182 [info] Client(client_1@183.82.98.119:49025): RECV PINGREQ(
Q0, R0, D0)
04:34:39.182 [info] Client(client_1@183.82.98.119:49025): SEND PINGRESP
(Q0, R0, D0)
04:34:45.181 [info] Client(client_1@183.82.98.119:49025): RECV PINGREQ(
Q0, R0, D0)
04:34:45.182 [info] Client(client_1@183.82.98.119:49025): SEND PINGRESP
(Q0, R0, D0)

$ ./bin/emqttd_ctl trace client "client_1" off #turn off tracing

and things seem to work fine. But for some reason, 2 issues happen

  1. The LWT does not get fired if the broker does not receive a PINGREQ from a client. It fires the LWT after 30+ seconds. Not sure why this is happening.

  2. The client randomly disconnects and connects and at this time, the LWT gets fired immediately.

The above 2 issues are disrupting the connection stability of the client.

We have connected to the same broker using https://github.com/mqttjs with the same timeout and there seems to be no issue with connectivity as well as firing LWT.

Can you please let me know if I am missing anything?

Thanks,
Arvind.

@arvindr21

Based on http://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament LWT should be fired when

  1. An I/O error or network failure is detected by the server.
  2. The client fails to communicate within the Keep Alive time.
  3. The client closes the network connection without sending a DISCONNECT packet first.
  4. The server closes the network connection because of a protocol error.

Looks like 2 & 3 points above seem to not work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment