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

Will Message is not published when client sends Disconnect Notification with Reason Code 0x04 (Disconnect with Will Message) #1291

Closed
wlisac opened this issue Aug 16, 2019 · 7 comments · Fixed by #1297

Comments

@wlisac
Copy link

wlisac commented Aug 16, 2019

Environment

  • VerneMQ Version: 1.9.0
  • Docker: erlio/docker-vernemq:latest
  • VerneMQ configuration (vernemq.conf) default, with this env var set:
    • DOCKER_VERNEMQ_LISTENER__TCP__ALLOWED_PROTOCOL_VERSIONS=3,4,5
  • Cluster size/standalone: Single docker container

Expected behavior

I'm expecting the client's Will Message to be published when the client sends a Disconnect Notification with Reason Code 0x04 (Disconnect with Will Message).

Actual behaviour

  • Connect to VerneMQ broker with a Will Message (and Will Delay Interval of 0) using version 5.0 of the MQTT protocol
  • Send Disconnect Notification with Reason Code 0x04 (Disconnect with Will Message)
  • Close network connection

The server does not publish the Will Message.

Additional Notes

Note that if the client closes the connection and doesn't send the Disconnect Notification with Reason Code 0x04, the Will Message is published.

I'm working on writing an MQTT client and I'm hoping to understand if this might be a bug in VerneMQ.

cc @larshesel

Happy to provide more details as needed.

Thanks,
Will

@ioolkos
Copy link
Contributor

ioolkos commented Aug 16, 2019

@wlisac thanks for reporting... interesting, I think you're correct and the will message should be published in that case.
Pinging @larshesel for an expert opinion.

@wlisac
Copy link
Author

wlisac commented Aug 16, 2019

It looks like mosquitto recently had the opposite issue – the LWT was being published on a clean disconnect. eclipse/mosquitto#1367

@larshesel
Copy link
Contributor

Hi, sounds like something we missed. We'll look into it.

@larshesel larshesel added this to the 1.9.2 milestone Aug 22, 2019
@larshesel
Copy link
Contributor

Hi @wlisac, I'm working on a fix for this and will hopefully have a PR ready later today. It's clear from the spec that if the client sends DISCONNECT with 0x00 normal disconnect, then the server must not send the LWT. And it's clear what the meaning is when the client sends a DISCONNECT with 0x04 Disconnect Notification with Will Message. It's not completely clear to me what should happen if the client sends a DISCONNECT with other reason codes. I'm leaning towards that the LWT should be sent then as well.

If that's the case then on DISCONNECT the only case where we should not send is if the reason code is 0x00 and in all other cases we send/schedule the LWT.

Does that make sense with your interpretation?

@larshesel
Copy link
Contributor

@wlisac, would you be able to test out the PR and if it works as expected?

@larshesel larshesel added the bug label Aug 23, 2019
@wlisac
Copy link
Author

wlisac commented Aug 26, 2019

@larshesel yep – I interpret it the same way.

I had a chance to test out the branch and it's now working as expected, thank you!

As a side note, I've noticed that the will delay interval is not working as expected, but I'm happy to open a separate issue for that.

Thanks again for the quick response :)

– Will

@wlisac
Copy link
Author

wlisac commented Aug 26, 2019

Opened #1298 as a follow up for the Will Delay Interval.

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

Successfully merging a pull request may close this issue.

3 participants