I have this:
<script>
const socket = new WebSocket('ws://localhost:3702');
socket.addEventListener('open', function (event) {
console.log('connection made to server:', event);
});
socket.addEventListener('message', function (event) {
console.log('ws client received message:', event);
location.reload();
});
</script>
it won't auto-reconnect, if the server restarts. What is the best way to reconnect to the server?