0

If a client is connected to a webserver via websockets, and say the client closes unexpectedly without the client issuing websocket.close(), say the process died or something.

What happens at that point, does the server close the connection automatically?

Shai UI
  • 50,568
  • 73
  • 204
  • 309

1 Answers1

0

Yes, it will be closed because it's a "2 side connection". As mentioned in comments by bestinamir, if connection's dropped at either side, the interaction will end.

  • However, you can try to avoid that issue with this (answer from kanaka): https://stackoverflow.com/questions/4812686/closing-websocket-correctly-html5-javascript – Mauricio Cárdenas Apr 18 '19 at 20:38
  • why would I attempt to close it manually (as mentioned in comment above) if it disconnects automatically if the client closes process? – Shai UI Apr 18 '19 at 20:44
  • It kinda depends on the browser. Firefox keeps the connection open, so the "onclose" event normally triggers anyway. Let's say the browser crashes, the connection is interrupted and the connection will stop too. Maybe if you post some of your code I would be able to better explain the situation. – Mauricio Cárdenas Apr 18 '19 at 20:56