Answer the question
In order to leave comments, you need to log in
Why does the websocket in Chrome and Firefox not immediately close when the connection is broken?
Situation: it is necessary to notify the user on the page about the interruption of the Internet connection and ensure the integrity of the data that should have been sent to the websocket at the time of the interruption.
What happens and how to reproduce: after loading the page, js establishes a webosocket connection, turn off wi-fi on the device and catch the connection close event.
const ws = new WebSocket('wss://.......');
ws.onopen = () => { ... };
ws.onclose = () => { console.log('Websocket was closed')};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question