feat: Removed disconnect on error while parsing a message
This commit is contained in:
@@ -138,19 +138,22 @@ class PythonWebsocketServer:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
async for message in websocket:
|
async for message in websocket:
|
||||||
|
try:
|
||||||
|
message_json = json.loads(message)
|
||||||
|
if ('type' not in message_json or
|
||||||
|
'uuid' not in message_json or
|
||||||
|
'data' not in message_json):
|
||||||
|
self.logger.error(f'[PyG2O] Expected message with (type, uuid, data) fields, got: {message_json}')
|
||||||
|
continue
|
||||||
|
|
||||||
message_json = json.loads(message)
|
await self._callMessage(message_json['type'], message_json)
|
||||||
if ('type' not in message_json or
|
|
||||||
'uuid' not in message_json or
|
|
||||||
'data' not in message_json):
|
|
||||||
return
|
|
||||||
|
|
||||||
await self._callMessage(message_json['type'], message_json)
|
except json.JSONDecodeError as e:
|
||||||
|
self.logger.exception(f'[PyG2O] JSON Exception: {e}')
|
||||||
except json.JSONDecodeError as e:
|
continue
|
||||||
self.logger.exception(f'[PyG2O] JSON Exception: {e}')
|
except Exception as e:
|
||||||
except Exception as e:
|
self.logger.exception(f'[PyG2O] Exception: {e}')
|
||||||
self.logger.exception(f'[PyG2O] Exception: {e}')
|
continue
|
||||||
finally:
|
finally:
|
||||||
if (not self.silent):
|
if (not self.silent):
|
||||||
self.logger.info('Client disconnected')
|
self.logger.info('Client disconnected')
|
||||||
|
|||||||
Reference in New Issue
Block a user