Retrieving published messages on subscribe after disconnect

228 views
Skip to first unread message

Sam Matthews

unread,
Mar 11, 2014, 1:37:50 PM3/11/14
to mq...@googlegroups.com
HI, I'm new to MQTT and trying to understand how it works.

I have set up a simple node js chat program. I am connecting to 'test.mosca.io' over websockets.  I can run multiple copies of my browser app and can chat back and forth just fine.

What i can't understand (and I've been plodding through the docs all day) is how  client A should receive published messages from client B when it is disconnected and resubscribes to the topic.

My steps and parameters are as follows.

Client A
 - connect to broker, cleanSession = false
- subscribe to topic 'xyz' with unique client id 'AAA'

Client B
 - connect to broker, cleanSession = false
- subscribe to topic 'xyz' with unique client id 'BBB'
  
Client A send message to Client B - message received
Client B send message to Client A - message received

Client A disconnects from broker, but does not unsubscribe from 'xyz'
Client B send message to Client A

Client A
 - connect to broker, cleanSession = false
- subscribe to topic 'xyz' with the same client id 'AAA'

Message from Client B not appear in MessageArrived.

I think this should be working and I can't see what I've missed :-(

Any help much appreciated....

Sam

Nicholas O'Leary

unread,
Mar 11, 2014, 2:07:34 PM3/11/14
to mq...@googlegroups.com

Hi Sam

What QoS are you using to send the messages?

Brokers are not required to store qos0 messages for offline clients.

Nick

--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQ Telemetry Transport" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at http://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/d/optout.

Karl P

unread,
Mar 11, 2014, 6:47:16 PM3/11/14
to mq...@googlegroups.com

I'm guessing this is sam from #mqtt this afternoon, who had a pretty identical
problem. He actually fixed it, it was a mixup with client ids vs message ids,
once he had actually fixed client ids, it was working properly for him.

Cheers,
Karl P


On 03/11/2014 06:07 PM, Nicholas O'Leary wrote:
> Hi Sam
>
> What QoS are you using to send the messages?
>
> Brokers are not required to store qos0 messages for offline clients.
>
> Nick
>
> On 11 Mar 2014 18:05, "Sam Matthews" <smatth...@gmail.com
> <mailto:smatth...@gmail.com>> wrote:
>
> HI, I'm new to MQTT and trying to understand how it works.
>
> I have set up a simple node js chat program. I am connecting to
> 'test.mosca.io <http://test.mosca.io>' over websockets. I can run multiple
> <mailto:mqtt+uns...@googlegroups.com>.
> To post to this group, send email to mq...@googlegroups.com
> <mailto:mq...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/mqtt.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> To learn more about MQTT please visit http://mqtt.org
> ---
> You received this message because you are subscribed to the Google Groups "MQ
> Telemetry Transport" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to mqtt+uns...@googlegroups.com <mailto:mqtt+uns...@googlegroups.com>.
> To post to this group, send email to mq...@googlegroups.com
> <mailto:mq...@googlegroups.com>.
Message has been deleted

Sam Matthews

unread,
Mar 12, 2014, 2:08:16 PM3/12/14
to mq...@googlegroups.com
Yes, Hi...l and thank you very much for your help.  The QOS is 1.  

Yes the problem was that I was creating a new client id on each connection, not understanding the significance of persisting it.  After I fixed that it worked well.

I am working on a project for fun, and to learn thoroughly MQTT.  Some concepts I would like to tackle are....

 - MQTT authentication
 - connect over a secure web sockets connection.
 - other types of data that can be sent over the wire - like images.
 - MQTT clients on Android, IOS

... so hopefully I'll be back with more questions.

Thanks,
Sam 

Reply all
Reply to author
Forward
0 new messages