I’ve observed that Firefox often sends a ping message over an open WebSocket connection when I disconnect a network cable from my computer. I’m curious if this is a documented behavior or if it’s specified in the WebSockets RFC.
Here are the steps to reproduce this behavior:
- Connect two network cables to your computer, with one providing an internet connection.
- Open the developer console in Firefox.
- Establish a new WebSocket connection with any WebSocket server. For instance, you can use https://echo.websocket.org/.
- Disconnect the network cable that isn’t providing the internet connection.
- Check the network inspector. You should see a message with the text ‘PING’ and opcode 9 sent over the WebSocket.
- Plug in the cable again, anoter PING is sent.
Does anyone have any insights on this? I couldn’t find a reference of this behavior on MDN.