Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] mosquitto client publish success, but server does not receive data ?

You need to keep calling loop(). For qos2 there are multiple back
and forths. the return code from publish can only say that it has
been accepted by the library.

You either need to loop_start() and loop_stop(), or call loop()
repeatedly until your on_publish() callback fires for the MID you
received from the publish call.

This is a relatively common problem in code that attempts to
publish once and then exit. They exit well before the message is
actually published.

Sincerely,
Karl Palsson


Manu Abraham <abraham.manu@xxxxxxxxx> wrote:
> Greetings,
> 
> After a bit of a tussle with the client code,
> mosquitto_publish() apparently states a successful publish.
> 
> But unfortunately, the server does not receive the data, but
> states Socket error on client. It is a bit bewildering to me
> that the data got published, but the server did not receive
> any.
> 
> Any idea, what I am incorrectly doing ?
> (Attached the code, my mail client messes up plain text emails
> ..)
> 
> Thanks,
> 
> Manu
> 
> 
> 
> On the client side, I see thus:
> 
> ...
> Mosquitto lib initialized, ret: 0
> New Mosquitto Session instantiated
> Dont verify Server Hostname in Certificate ...
> 16 Client mosq-Rd9dsJ1bWTrYF7cjnE sending CONNECT
> Connected to Broker:  192.168.1.34 : 8883
> 16 Client mosq-Rd9dsJ1bWTrYF7cjnE sending PUBLISH (d0, q2, r0,
> m1, 'Testing', ... (12 bytes)) Publish success 16:39:20:
> D:\Work\Test
> Apps\Qt_Mosquitto\build-QMosquitto-Desktop_Qt_5_15_0_MSVC2019_64bit-Debug\debug\QMosquitto.exe
> exited with code 0
> 
> But on the server side all I see:
> 
> PS C:\Program Files\mosquitto> .\mosquitto.exe -c
> .\mosquitto.conf -v 1599044951: mosquitto version 1.6.10
> starting 1599044951: Config loaded from .\mosquitto.conf.
> 1599044951: Opening ipv6 listen socket on port 8883.
> 1599044951: Opening ipv4 listen socket on port 8883.
> 1599044954: New connection from 192.168.1.34 on port 8883.
> 1599044954: Socket error on client <unknown>, disconnecting.
> 1599045521: mosquitto version 1.6.10 terminating PS C:\Program
> Files\mosquitto>
> _______________________________________________ mosquitto-dev
> mailing list mosquitto-dev@xxxxxxxxxxx To unsubscribe from this
> list, visit
> https://www.eclipse.org/mailman/listinfo/mosquitto-dev

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


Back to the top