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

mosquitto_disconnect followed by mosquitto_connect_async fails to reconnect #2242

Closed
tiolan opened this issue Jun 29, 2021 · 2 comments
Closed
Labels
Component: libmosquitto Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Milestone

Comments

@tiolan
Copy link

tiolan commented Jun 29, 2021

There is a behavior, that I did not expect. Not sure whether this is really a bug, or intended behavior.
I am on version 2.0.11.

This is what I do on client side, in order to connect to mosquitto broker:

    mosquitto_new
    mosquitto_int_option
    mosquitto_connect_v5_callback_set
    mosquitto_disconnect_v5_callback_set
    mosquitto_publish_v5_callback_set
    mosquitto_message_v5_callback_set
    mosquitto_subscribe_v5_callback_set
    mosquitto_unsubscribe_v5_callback_set
    mosquitto_log_callback_set
    mosquitto_loop_start
    mosquitto_connect_async

Then I see a thread running, handling the I/O and the client is properly connected to the broker.
I do then call mosquitto_disconnect, which closes the connection.

Then calling mosquitto_connect_async again, I would expect the connection to be established again.
But what I see in Wireshark is, that it opens the TCP connection but does not send any MQTT package.
It provides the log "Client sending CONNECT" but does not actually send the CONNECT package.
Even if I call mosquitto_loop_start before mosquitto_connect_async it makes no difference, the thread is not started again.

Is my expectation correct?

@ralight
Copy link
Contributor

ralight commented Aug 24, 2021

Sorry for the delay looking into this. The problem was that calling disconnect causes the thread to stop, but not set the parameters that show the thread is no longer in use, meaning that calling mosquitto_loop_start() again wouldn't work. I've fixed this and it will be in 2.0.12 shortly.

@ralight ralight added this to the 2.0.12 milestone Aug 24, 2021
@ralight ralight added Component: libmosquitto Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug labels Aug 24, 2021
@ralight ralight closed this as completed in 0d1837e Sep 1, 2021
@me21
Copy link

me21 commented Feb 11, 2022

Workaround: You need to disable threaded mode manually by calling mosquitto_threaded_set after mosquitto_disconnect if you can't upgrade to the new version for some reason.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: libmosquitto Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Projects
None yet
Development

No branches or pull requests

3 participants