This repo has two things:
-
basic-server.js: Implements a very. basic. websocket server and prints any message it gets as well as when there's a new connection or a connection is closed
-
basic-client.html: A very. basic. webpage that:
- connects to the websocket on 'load'
- sends a last message and closes the websocket on 'unload' or 'beforeunload' (your choice based on what you've got uncommented :) )
npm i
npm run serve
- open /path/to/basic-client.html in the browser of choice
- open the console and be sure to have it set to preserve logs
- try refreshing/navigating away/closing the tab and watching the output in the server to see when unload/beforeunload succeeds
On 10.14.21, here were the results of this test