🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Chat issue

Started by
1 comment, last by frob 3 years, 4 months ago

Hi,
Currently, I'm working on an agar.io-like game.

I have a problem with sending text messages via chat. Most of the time it is working fine, but later text messages couldn't be sent.
For communication, I use WebSockets between server and client.
How should I debug to find the cause of the error?

Advertisement

The usual approach is tons of logging. Log what each side sends and what it receives. Log errors and network status information. Log events that come from the library. Log exceptions, log return codes including success. Make certain you're capturing and logging every possible error code and success code the library exposes. Then pick that logging apart to look for patterns.

The Internet is inherently unreliable, although usually on modern connections they're mostly good. Errors will happen. WebSockets under the hood are TCP connections, so they handle many errors automatically at the cost of performance when the errors occur.

You'll need to pay attention to whatever the log reveals. Maybe messages are getting fragmented. Maybe messages are too big for the sub-protocol you're using. Maybe there was an error in a subsystem you were using. Maybe connections are broken or timed out and being automatically re-established. Whatever it is, logging will help reveal it.

If it doesn't become obvious with the logs, you'll need to add more diagnostic steps on your own. These start with looking at data that crossed boundaries. Was the data actually sent from the client out across the wire? If it was sent, was it received across the wire? You may need to use a tool like Wireshark to be absolutely certain. If it was received, was it processed? Once you've got a point of failure (processing before transmission, mid transmission, processing after transmission) you can hunt down the particulars.

This topic is closed to new replies.

Advertisement