FAForever / FAForever/server

Better logging for malformed messages

Open
#661 0 comments 0 reactions 0 assignees View on GitHub
good first issue
Dominant language
Python
Stars
72
Forks
84
Avg merge
5h 11m
Merged PRs (30d)
1

Description

There are a number of mysterious errors which indicate that sometimes clients are sending malformed protocol messages:

```
ERROR Sep 03 21:05:08 ServerContext Invalid control character at: line 1 column 728 (char 727)
Traceback (most recent call last):
File "/code/server/servercontext.py", line 80, in client_connected
message = await protocol.read_message()
File "/code/server/protocol/qdatastreamprotocol.py", line 119, in read_message
message = json.loads(action)
File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.7/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid control character at: line 1 column 728 (char 727)
```

```
ERROR Sep 02 20:31:37 ServerContext Expecting ',' delimiter: line 1 column 10652 (char 10651)
Traceback (most recent call last):
File "/code/server/servercontext.py", line 80, in client_connected
message = await protocol.read_message()
File "/code/server/protocol/qdatastreamprotocol.py", line 119, in read_message
message = json.loads(action)
File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.7/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 10652 (char 10651)
```

We should probably have some explicit error handling that expects these sorts of errors and logs the entire message. These could easily be caused by non FAF traffic like automated portscans or something, but if they are legitimate messages, then maybe there is a bug in the client somewhere.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.