njh / ruby-mqtt

Pure Ruby gem that implements the MQTT protocol, a lightweight protocol for publish/subscribe messaging.
http://www.rubydoc.info/gems/mqtt
MIT License
541 stars 135 forks source link

Offline persistence with clean_session #109

Closed csoreff closed 6 years ago

csoreff commented 6 years ago

If I pass clean_session: false to client, everything seems to break with #0 Protocol error occurs.,MQTT::ProtocolException,Failed to read byte from socket. Is there a known method for persisting when internet connection is lost? Trying to use a custom fork of https://github.com/toyokazu/fluent-plugin-mqtt-io/tree/remove_reconnection_and_add_qos_retain to allow offline persistence, but having some trouble.

njh commented 6 years ago

clean_session: false is for server-side persistence. The server should queue-up messages while the client is offline and deliver them when the client re-connects. This should be working fine.

Client-side persistence (i.e. messages trying to be sent while the client is offline) is not currently supported and is covered by #52.