ebSocket.OPEN) {
                    socket.send('ping');
                }
            }, 10000);

            socket.addEventListener("close", (event) => {
                console.log("Socket closed");
                socket = null
                clearInterval(pingInterval)	// Stop pinging
                startReconnectPolling()	// Start retrying			
            });
        });

        // When a command goes to the `sendMessage` port, we pass the message
        // along to the WebSocket.
        app.por