I have a node HTTPS linux server which handles UPGRADE requests to allow secure WebSocket connections as well as other HTTPS requests. Works well 99% of the time.
Periodically and unpredictably, client websocket connection attempts to the server timeout (client gives up after 30 seconds).
I listen for upgrade requests on the HTTPS server as follows:
server.on('upgrade', function upgrade(req, socket, head) {
console.log('Upgrade - Beg - '+req.url);
...
In the cases where the client timeout occurs, I never get the 'upgrade' event.
How can I debug this? Is there a lower-level Node https server event that I can listen for that might indicate something (so that I know the connection is actually getting to the server, for example)?
Notes:
When I detect the timeout on the client side (actually, even before the 30 seconds), I attempt another HTTPS connection to the same server (a POST). It works! The problem only seems to happen with websocket connections.
I have code that retries the websocket connection when it experiences the timeout, but usually it takes several retries before the timeout magically disappears.
Any help in how to debug this would be greatly appreciated.