Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] Client receives PUBREC and MQTT disconnected

Hi Khitai,

As Ian says, libmosquitto doesn't support disk based persistence.
Given that, it probably shouldn't produce an error if it receives a
PUBREC for an unknown message id. That latter bit is an easy fix at
least - adding disk persistence would be a little bit more involved.

Cheers,

Roger



On Mon, Nov 16, 2015 at 8:34 AM, Khitai Pang <khitai.pang@xxxxxxxxxxx> wrote:
> Yes I'm using QoS 2.  How to persist the inflight message state using
> libmosquitto?
>
> Regards,
> Khitai
>
>
> On 2015/11/13 23:17, Ian Craggs wrote:
>>
>> One reason could be that client library does not store MQTT state across
>> application stops and restarts.
>>
>> If the application is stopped when some MQTT QoS 2 exchanges are
>> incomplete and the MQTT client library does not persist the inflight message
>> state (to disk for example), there will be a mismatch between broker and
>> client state.
>>
>> The Paho Java and C (not embedded) clients do allow you to persist
>> inflight data to disk, so that when the application is restarted, the state
>> of inflight MQTT messages is restored, and this situation would not occur.
>>
>> Ian
>>
>> On 11/13/2015 01:50 AM, Khitai Pang wrote:
>>>
>>> Connecting with cleansession=true solved the problem, but all offline
>>> messages are lost.
>>>
>>> Why is the client receiving a PUBREC that it doesn't know how to handle?
>>> What is going wrong here?
>>>
>>> Thanks
>>> Khitai
>>>
>>> On 2015/11/12 18:37, Ian Craggs wrote:
>>>>
>>>> Have you tried connecting with cleansession=true to clean up the state
>>>> for that client id?
>>>>
>>>> Ian
>>>>
>>>> On 11/12/2015 08:23 AM, Khitai Pang wrote:
>>>>>
>>>>> Here's what happened:
>>>>>
>>>>> _mosquitto_handle_pubrec handles the received PUBREC, then
>>>>> _mosquitto_message_out_update updates the message's out status, but in this
>>>>> function mosq->out_messages is NULL, so MOSQ_ERR_NOT_FOUND is returned,
>>>>> _mosquitto_loop_rc_handle handles the response code, since it's an error,
>>>>> finally _mosquitto_socket_close(mosq) is called.
>>>>>
>>>>> Regards
>>>>> Khitai
>>>>>
>>>>> On 2015/11/12 15:08, Khitai Pang wrote:
>>>>>>
>>>>>> Got rc=6 in the ondisconenct callback.
>>>>>>
>>>>>> Regards
>>>>>> Khitai
>>>>>>
>>>>>> On 2015/11/12 14:43, Khitai Pang wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I am having problem with a particular MQTT client ID. When a client
>>>>>>> connects to Mosquitto using this ID, it immediately receives a PUBREC from
>>>>>>> the broker and then MQTT get disconnected:
>>>>>>>
>>>>>>> 2015-11-10 20:35:21.827 mqtt-test[58102:737651] === MQTT connected===
>>>>>>> 2015-11-10 20:35:22.329 mqtt-test[58102:737651] mosquitto log :
>>>>>>> Client 362f23d0-8906-11e5-99da-005056355a83 received PUBREC (Mid: 58)
>>>>>>> 2015-11-10 20:35:22.454 mqtt-test[58102:737651] === MQTT
>>>>>>> disconnected===
>>>>>>>
>>>>>>> Log on the broker side:
>>>>>>>
>>>>>>> ...
>>>>>>> testhost mosquitto[4911]: New client connected from ... as
>>>>>>> 362f23d0-8906-11e5-99da-005056355a83 (c0, k120).
>>>>>>> testhost mosquitto[4911]: Socket error on client
>>>>>>> 362f23d0-8906-11e5-99da-005056355a83, disconnecting.
>>>>>>> ...
>>>>>>>
>>>>>>> The broker is mosquitto 1.3.5.  The client uses libmosquitto in
>>>>>>> mosquitto 1.4.4.
>>>>>>>
>>>>>>> Any help is appreciated.
>>>>>>>
>>>>>>>
>>>>>>> Regards,
>>>>>>> Khitai
>>>>>>> _______________________________________________
>>>>>>> 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
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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
>>
>>
>
> _______________________________________________
> 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