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 istimernode test2- Which receives the messages for the topictimerstop node test2- Stop this application now we can see the messages are still publishing by thenode testserver but the messages our server 2node test2is 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