moscajs / mosca

MQTT broker as a module
mosca.io
3.2k stars 509 forks source link

forwardRetained for qos=1 subscriptions #540

Open behrad opened 8 years ago

behrad commented 8 years ago

If a client is subscribing a qos=1 topic, but not issuing the subscribe command on each reconnect, retained messages are not forwarded, however I think they should!

This is since forwardRetained is called inside handleSubscribe https://github.com/mcollina/mosca/blob/master/lib/client.js#L496, but should be moved inside restoreClientSubscriptions or authorizeSubscribe so that it gets called on each subscription restore.

mcollina commented 8 years ago

I do not think retained messages should be forwarded in this case. Have you tried this with mosquitto or another MQTT broker and checked if they behave like Mosca?

  1. client A has a QoS 1 subscription
  2. client A goes offline
  3. client B publishes a retained message with QoS 0
  4. client A should or should not receive the retained message

I think it should not. If this is still unclear from the spec, we might ask it to be clarified/fixed.

behrad commented 8 years ago

This topic is about the following scenario:

  1. client A has a QoS 1 subscription
  2. client A goes offline
  3. client B publishes a retained message with QoS 1
  4. client A connects (without sending a subcribe)
  5. client A should receive the retained message

here A should receive the message, however it currently doesn't.

mcollina commented 8 years ago

Yes, absolutely.

Would you mind sending a PR?

benlikeshotchocolate commented 7 years ago

I'm having the same issue as described above.