Running the sub program, you can send 1,000,000 messages to it and will see that it exit and reports the performance (you can use examples/nats-publisher or examples/nats-libuv-pub for that). Restart the sub, and this time stop the NATS Server, you will see that the sub program is still connected. Now restart the server, and then restart your publisher and you should see that the sub receive them all (it did reconnect). To see that the sub program would exit if the NATS Server is not restarted, you would have to wait for the max reconnect/delay to pass. By default it is 60 attempts with 2sec in between, so it may be a bit long. You could add these lines
here and recompile to speed it up: