Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] How to determine status of network loop

use the non-threaded interface if you need more fine grained

Tony Klein <tklein@xxxxxxxxxxx> wrote:
> I am a client using libmosquitto to connect to a broker over
> TLS.
> I am having difficulty determining the status of the network
> thread, or alternately the status of my connection attempt.
> I call mosquitto_loop_start()
> then mosquitto_connect()
> then wait forĀ  on_connect() callback to get driven.
> Perhaps the broker name does not resolve,
> or perhaps the connection is refused (broker not running), or
> perhaps the server or client certificates don't validate
> properly, or perhaps any number of misadventures occur.
> Sometimes the connection will eventually succeed,
> but sometimes it does not.
> How can my client determine what to do next?
> In some cases its appropriate to simply wait, because the
> network thread is working, (For example, suppose the broker is
> not running: mosquitto_connect() returns a "connection refused"
> error, I can essentially ignore ... start the broker and the
> connection completes as if by magic. Amazing.)
> in other cases its hopeless because the network thread has
> exited and the waiting would be forever. (For example if either
> server or client certificates fail to validate properly.
> Bummer. No error return on connect(), no callback, no clue.)
> How do I know the difference?
> What technique can I use to determine if the network thread is
> running, or to resolve faults that may have occurred?
> Regards,
> Tony
> St. Paul, Minnesota, USA
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To unsubscribe from this list, visit

Attachment: OpenPGP-digital-signature.html
Description: OpenPGP Digital Signature

Back to the top