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

Wait for graceful MQTT disconnect #2374

Merged
merged 1 commit into from
Sep 28, 2020
Merged

Conversation

feymartynov
Copy link
Contributor

On destroy MQTT transport publishes a offline status message and then calls MQTTAsync_disconnect which gracefully disconnects from the broker by sending disconnect message. However this call is asynchronous and is not being awaited and the socket closes faster than the message is being sent. From the point of view of the broker it looks like ungraceful disconnection so it publishes another one offline status message as LWT. As a result subscribers get duplicated offline status messages.

This PR fixes this problem by synchronizing MQTTAsync_disconnect call using janus_condition_wait_until.

Copy link
Member

@lminiero lminiero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you tested this, and that it now works as expected, so apart from the note I added this looks good to me. As soon as the note is addressed I'll merge, thanks 👍

transports/janus_mqtt.c Outdated Show resolved Hide resolved
@feymartynov
Copy link
Contributor Author

Sure, I've tested it.

@lminiero
Copy link
Member

Thanks, merging then 👍

@lminiero lminiero merged commit 1da5aa2 into meetecho:master Sep 28, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants