eclipse / paho.mqtt.javascript

paho.mqtt.javascript
Other
1.14k stars 468 forks source link

How to get offline messages? #146

Closed DayTimeDreamer closed 5 years ago

DayTimeDreamer commented 6 years ago

Hello! How to get offline messages after reconnected? Thank you!

jpwsutton commented 6 years ago

Hi, If you are connecting with cleanSession=true then once you reconnect, the client will receive all messages that were published on it's subscriptions whilst it was offline.

DayTimeDreamer commented 6 years ago

@jpwsutton Hi! Thank you for your reply. I use paho.mqtt.javascript with mosca and set cleanSession=true, then it doesn't work.

crmolinaz commented 6 years ago

I think he means cleanSession=false

DayTimeDreamer commented 6 years ago

I've set cleanSession=false and it doesn't work. So I used ActiveMQ instead of Mosca, then it work well.

icraggs commented 6 years ago

So that could be a problem with Mosca? You could try with another client library to verify.

karlp commented 5 years ago

you also need to have a subscription from before with a qos >= 1. and you need to reconnect using the same client id. It's not just "cleansession=false"