Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] connect_async problem and advice publish/dedconnect needed

Hi Markus,

With connect_async I think the problem is a check for !=0 that should be >0. In lib/mosquitto.c around line 520 if you change "if(rc){" to "if(rc>0){" does your code work? In this case you should also only treat a >0 return code as an error.

With regards to sending messages, this is an entirely asynchronous process and for QoS>0 will depend on the speed that the broker responds at. You can be happy that your message has been sent once the publish callback has been called.



On Mon, Apr 27, 2015 at 2:18 PM, Bayerlein, Markus (I/AEV-23) <markus.bayerlein@xxxxxxx> wrote:

Hi there.


As already stated in the email subject, I encounter two problems with the Mosquitto library and hope for some advice.

1.     I can’t connect to an MQTT broker using ‘connect_async’. The return value of the function is ‘-1’ (= MOSQ_ERR_CONN_PENDING). The connack string returned is ‘Connection Refused: unknown reason.’ and the error string is ‘Operation now in progress ’ The broker I try to connect to is mosquitto (v1.4.1). Using ‘connect’ works fine.

2.     When I publish a message and disconnect immediately thereafter, the message sometimes is not sent (actually, it depends on the QoS: messages with QoS 0 or 1 are sometimes not sent, Qos 2 messages never) . If I do a sleep(1) before the disconnect, all messages are delivered correctly. I am sure there is a better solution than waiting for a second. How do I ensure that all messages are sent before a disconnect?


Thanks in advance



Mit freundlichen Grüßen / Kind regards


Markus Bayerlein

Entwicklung Datenanalytik


Audi Electronics Venture GmbH


Sachsstr. 20

85080 Gaimersheim


Tel.: +49-841-89-714755

Mobil: +49-1525-7714755



Beschreibung: C:\Users\TEMARIE\Desktop\Email_Signatur_Option1.jpg


Sitz/Domicile: Gaimersheim

Registergericht/Court of Registry: Amtsgericht Ingolstadt

HRB Nr./Commercial Register No.: 3083

Geschäftsführer/Managing Director: Dr. Peter Steiner


Wichtige Hinweise: Die vorgenannten Angaben werden jeder E-Mail automatisch hinzugefügt und lassen keine Rückschlüsse auf den Rechtscharakter der E-Mail zu. Erklärungen der Audi Electronics Venture GmbH mit rechtlich bindendem Inhalt, insbesondere der Verzicht auf Rechte am geistigen Eigentum, bedürfen der Zustimmung durch vertretungsberechtigte Personen der Audi Electronics Venture GmbH.

Die Inhalte dieser E-Mail und jegliche Anhänge sind vertraulich. Der rechtmäßige Empfänger ist zur Nutzung der Inhalte nur im Rahmen des vorgesehenen Zwecks berechtigt. Zur Veröffentlichung oder Weitergabe an Unberechtigte ist der Empfänger nicht berechtigt. Eine Zuwiderhandlung kann sowohl zivilrechtliche als auch strafrechtliche Folgen haben. Sofern Sie nicht der rechtmäßige Empfänger sind, bitten wir Sie den Absender unverzüglich durch Rücksendung dieser E-Mail zu informieren und diese E-Mail anschließend zu löschen. Vielen Dank.

Important notices: The above information is automatically added to this e-mail. This addition does not allow conclusions that the content of this e-mail is legally relevant. Legally binding statements, particularly a waiver of any intellectual property right, require agreement of the authorized representatives of Audi Electronics Venture GmbH.

This e-mail and any attachments are confidential. The legitimate recipient is only permitted to use the content in respect to the intended purpose. The recipient is not permitted to publish or forward the content to unauthorized persons. Violation of these rules may result in both civil and criminal prosecution. If you are not the intended recipient, we ask you to notify the sender immediately by sending back this e-mail and delete this e-mail subsequently. Thank you.


mosquitto-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top