Update message loops sample to detect all duplicate messages then stop connection when new message is not duplicate instead of running forever

Currently message loops sample detect duplicate messages, but still continue run forever, in this case it could cause some difficult to look browser console logging and server trace log files too.

Here are changes:
1. Update message loops sample to detect all duplicate messages then stop the connection when new message is not duplicate instead of running forever, so it will be easy to investigate on client and server.
2. Update to not stop message loop  when send failed, e.g. send failed when reconnect , now message loops can continue after reconnect.