No traceback for OSError 113 in WSChiaConnection.outbound_handler() (#13016)

* No traceback for OSError 113 in WSChiaConnection.outbound_handler()

```python-traceback
Aug 16 21:24:08 fullnode chia_full_node[58416]: 2022-08-16T21:24:08.489 full_node full_node_server        : ERROR    Exception: [Errno 113] No route to host with 121.236.62.254
Aug 16 21:24:08 fullnode chia_full_node[58416]: 2022-08-16T21:24:08.490 full_node full_node_server        : ERROR    Exception Stack: Traceback (most recent call last):
Aug 16 21:24:08 fullnode chia_full_node[58416]:   File "/farm/chia-blockchain/chia/server/ws_connection.py", line 262, in outbound_handler
Aug 16 21:24:08 fullnode chia_full_node[58416]:     await self._send_message(msg)
Aug 16 21:24:08 fullnode chia_full_node[58416]:   File "/farm/chia-blockchain/chia/server/ws_connection.py", line 416, in _send_message
Aug 16 21:24:08 fullnode chia_full_node[58416]:     await self.ws.send_bytes(encoded)
Aug 16 21:24:08 fullnode chia_full_node[58416]:   File "/farm/chia-blockchain/venv/lib/python3.8/site-packages/aiohttp/web_ws.py", line 315, in send_bytes
Aug 16 21:24:08 fullnode chia_full_node[58416]:     await self._writer.send(data, binary=True, compress=compress)
Aug 16 21:24:08 fullnode chia_full_node[58416]:   File "/farm/chia-blockchain/venv/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 688, in send
Aug 16 21:24:08 fullnode chia_full_node[58416]:     await self._send_frame(message, WSMsgType.BINARY, compress)
Aug 16 21:24:08 fullnode chia_full_node[58416]:   File "/farm/chia-blockchain/venv/lib/python3.8/site-packages/aiohttp/http_websocket.py", line 659, in _send_frame
Aug 16 21:24:08 fullnode chia_full_node[58416]:     await self.protocol._drain_helper()
Aug 16 21:24:08 fullnode chia_full_node[58416]:   File "/farm/chia-blockchain/venv/lib/python3.8/site-packages/aiohttp/base_protocol.py", line 87, in _drain_helper
Aug 16 21:24:08 fullnode chia_full_node[58416]:     await asyncio.shield(waiter)
Aug 16 21:24:08 fullnode chia_full_node[58416]:   File "/usr/lib/python3.8/asyncio/selector_events.py", line 848, in _read_ready__data_received
Aug 16 21:24:08 fullnode chia_full_node[58416]:     data = self._sock.recv(self.max_size)
Aug 16 21:24:08 fullnode chia_full_node[58416]: OSError: [Errno 113] No route to host
Aug 16 21:24:08 fullnode chia_full_node[58416]:
```

* Update ws_connection.py

* refactor
This commit is contained in:
Kyle Altendorf 2022-08-17 02:03:10 -04:00 committed by GitHub
parent 764a5a2276
commit bd7ed405eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -254,7 +254,7 @@ class WSChiaConnection:
except Exception as e:
self.log.error(f"Failed setting event for {message_id}: {e} {traceback.format_exc()}")
async def outbound_handler(self):
async def outbound_handler(self) -> None:
try:
while not self.closed:
msg = await self.outgoing_queue.get()
@ -262,9 +262,17 @@ class WSChiaConnection:
await self._send_message(msg)
except asyncio.CancelledError:
pass
except (BrokenPipeError, ConnectionResetError, TimeoutError) as e:
self.log.warning(f"{e} {self.peer_host}")
except Exception as e:
expected = False
if isinstance(e, (BrokenPipeError, ConnectionResetError, TimeoutError)):
expected = True
elif isinstance(e, OSError):
if e.errno in {113}:
expected = True
if expected:
self.log.warning(f"{e} {self.peer_host}")
else:
error_stack = traceback.format_exc()
self.log.error(f"Exception: {e} with {self.peer_host}")
self.log.error(f"Exception Stack: {error_stack}")