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,

I think it could read more clearly, I'll update it.

Cheers,

Roger


On Wed, Apr 29, 2015 at 11:54 AM, Bayerlein, Markus (I/AEV-23)
<markus.bayerlein@xxxxxxx> wrote:
> I just re-read my own comment, and think it's nonsense. You are right, Karl, the mid is set by the publish call.
>
> Markus
>
> -----Urspr√ľngliche Nachricht-----
> Von: mosquitto-dev-bounces@xxxxxxxxxxx [mailto:mosquitto-dev-bounces@xxxxxxxxxxx] Im Auftrag von Bayerlein, Markus (I/AEV-23)
> Gesendet: Mittwoch, 29. April 2015 12:48
> An: General development discussions for the mosquitto project
> Betreff: Re: [mosquitto-dev] connect_async problem and advice publish/dedconnect needed
>
> Hi Karl.
>
> You seem to use the Paho libray, maybe it is handled differently there. Or is paho based on mosquitto??
> As for the MID parameter in mosquitto_publish: The api doc (http://mosquitto.org/api/files/mosquitto-h.html#mosquitto_publish) says:
>
> mid     pointer to an int.  *If not NULL*, the function will set this to the message id of this particular message.  This can be then used with the publish callback to determine when the message has been sent.  Note that although the MQTT protocol doesn't use message ids for messages with QoS=0, libmosquitto assigns them message ids so they can be tracked with this parameter.
>
> So if you provide a pointer to a defined int, this will be used for the message id (at least this is how I read it).
>
> Regards
>
> Markus
>
> -----Urspr√ľngliche Nachricht-----
> Von: mosquitto-dev-bounces@xxxxxxxxxxx [mailto:mosquitto-dev-bounces@xxxxxxxxxxx] Im Auftrag von Karl Palsson
> Gesendet: Mittwoch, 29. April 2015 12:06
> An: General development discussions for the mosquitto project
> Betreff: Re: [mosquitto-dev] connect_async problem and advice publish/dedconnect needed
>
>
> Interesting.  The loop_start/loop_stop behaviour I was proposing is how
> the python client works.
>
> See the bottom for a simple client that publishes all three before
> exiting.  I retested this with libmosquitto and indeed, loop_stop won't
> stop unless you call disconnect, and disconnect just exits, before
> you've finished the exchange.  Roger, is it really meant to be like
> that?
>
> One further note, you've made a common mistake, in that you're trying to
> _provide_ a MID in the publish call.  You don't provide a mid here, you get a MID written back to you.
>
> Cheers,
> Karl P
>
>
> ---------------------
> #!/usr/bin/env python
>
> import paho.mqtt.client as mqtt
>
> def on_connect(client, userdata, flags, rc):
>     print("Connected with result code "+str(rc))
>
> client = mqtt.Client()
> client.on_connect = on_connect
>
> client.connect("localhost", 1883, 60)
>
> client.loop_start()
>
> client.publish("test/topic", "dummy msg qos 0", 0)
> client.publish("test/topic", "dummy msg qos 1", 1)
> client.publish("test/topic", "dummy msg qos 2", 2)
>
> client.loop_stop()
>
> ------------------
>
>
> "Bayerlein, Markus (I/AEV-23)" <markus.bayerlein@xxxxxxx> wrote:
>> Hi.
> --- snip ---
>>         for ( qos = 0; qos <= 2; ++qos ) {
>>             ++msg_id;
>>             sprintf(msg, "my test message, QoS %d, id %d", qos, msg_id);
>>             mlen = strlen(msg);
>>             printf("sending message %d with QoS %d on topic %s\n", msg_id, qos, topic);
>>             if ( mosquitto_publish(m, &msg_id, topic, mlen, msg, qos, false) != MOSQ_ERR_SUCCESS ) {
>>                 perror("failed to publish message");
>>             }
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev
> _______________________________________________
> mosquitto-dev mailing list
> mosquitto-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/mosquitto-dev


Back to the top