Skip to content Skip to sidebar Skip to footer

How To Know The Reason Why A Websocket Client Is Closed Unexpectedly?

I have a browser game using ws module. But sometimes a client on a distant computer will close connection for unknown reason when playing the game for a while. The screen just free

Solution 1:

But sometimes a client on a distant computer will close connection for unknown reason when playing the game for a while.

Welcome to The Internet™, a notoriously hostile environment where anything that can go wrong, will.

Seriously, people cut fiber with backhoes all the time. Sometimes floods cause power outages. Other times, someone's laptop battery died. Lots of people use wireless access of some sort or another which is subject to all sorts of interference... by design! You won't ever really know why this happens. Eventually, a bunch of packets get lost, some threshold is exceeded, and the problem works its way through the layers.

A properly built application will deal with this gracefully. You can try to reconnect if you want.

Post a Comment for "How To Know The Reason Why A Websocket Client Is Closed Unexpectedly?"