server
server copied to clipboard
Better logging for malformed messages
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.