Refer this blog post
Implemented persistent session between connected clients with respect to broker
.
Connect should have clean
false so broker won't create new session on receonnect since the clientId is maintained same
Follow these steps for testing session.
node test
- which publishes the messages with time interval 5000ms. Topic istimer
node test2
- Which receives the messages for the topictimer
stop node test2
- Stop this application now we can see the messages are still publishing by thenode test
server but the messages our server 2node test2
is stopped.- lets start
node test2
- we can see the previously sent messages of the server1 are also received - so we can conculde the persistent session is maintaind
MIT