Skip to content

Commit dfdf05c

Browse files
committed
Handle invisible asyncio timeout error
1 parent 1af28a2 commit dfdf05c

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

src/collectors/cardano.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ async def _probe(self) -> results:
3838
results.record_latency(self.url, await fetch_latency(websocket))
3939
results.record_health(self.url, True)
4040
results.record_block_height(self.url, await self._blockHeight(websocket))
41+
except asyncio.exceptions.TimeoutError:
42+
logger.error(
43+
f"Timed out while trying to establish websocket connection. Current open_timeout value in config: {cfg.open_timeout}.",
44+
url=self.stripped_url)
45+
results.record_health(self.url, False)
4146
except Exception as exc:
4247
results.record_health(self.url, False)
4348
logger.error(f"{exc}", url=self.stripped_url)

src/collectors/conflux.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ async def _probe(self) -> results:
4646
results.record_client_version(self.url, await self._cfx_clientVersion(websocket))
4747
results.record_head_count(self.url, self.sub.head_counter)
4848
results.record_disconnects(self.url, self.sub.disconnects)
49+
except asyncio.exceptions.TimeoutError:
50+
logger.error(
51+
f"Timed out while trying to establish websocket connection. Current open_timeout value in config: {cfg.open_timeout}.",
52+
url=self.stripped_url)
53+
results.record_health(self.url, False)
4954
except Exception as exc:
5055
results.record_health(self.url, False)
5156
logger.error(f"{exc}", url=self.stripped_url)

src/collectors/evm.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ async def _probe(self) -> results:
4747
results.record_client_version(self.url, await self._web3_clientVersion(websocket))
4848
results.record_head_count(self.url, self.sub.head_counter)
4949
results.record_disconnects(self.url, self.sub.disconnects)
50+
except asyncio.exceptions.TimeoutError:
51+
logger.error(
52+
f"Timed out while trying to establish websocket connection. Current open_timeout value in config: {cfg.open_timeout}.",
53+
url=self.stripped_url)
54+
results.record_health(self.url, False)
5055
except Exception as exc:
5156
results.record_health(self.url, False)
5257
logger.error(f"{exc}", url=self.stripped_url)

src/settings.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,28 @@ def __init__(self, config_file_path: str, validation_file_path: str):
2121
try:
2222
self.open_timeout = self.configuration['connection_parameters']['open_timeout']
2323
except KeyError:
24-
logger.info("connection_parameters.open_timeout not set, defaulting to 5")
2524
self.open_timeout = 5
25+
logger.info(f"connection_parameters.open_timeout not set, defaulting to {self.open_timeout}")
2626
try:
2727
self.close_timeout = self.configuration['connection_parameters']['close_timeout']
2828
except KeyError:
29-
logger.info("connection_parameters.close_timeout not set, defaulting to 1")
30-
self.close_timeout = 1
29+
self.close_timeout = 4
30+
logger.info(f"connection_parameters.close_timeout not set, defaulting to {self.close_timeout}")
3131
try:
3232
self.response_timeout = self.configuration['connection_parameters']['response_timeout']
3333
except KeyError:
34-
logger.info("connection_parameters.response_timeout not set, defaulting to 5")
3534
self.response_timeout = 5
35+
logger.info(f"connection_parameters.response_timeout not set, defaulting to {self.response_timeout}")
3636
try:
3737
self.ping_interval = self.configuration['connection_parameters']['ping_interval']
3838
except KeyError:
39-
logger.info("connection_parameters.ping_interval not set, defaulting to 10")
4039
self.ping_interval = 10
40+
logger.info(f"connection_parameters.ping_interval not set, defaulting to {self.ping_interval}")
4141
try:
4242
self.ping_timeout = self.configuration['connection_parameters']['ping_timeout']
4343
except KeyError:
44-
logger.info("connection_parameters.ping_timeout not set, defaulting to 5")
4544
self.ping_timeout = 4
46-
45+
logger.info(f"connection_parameters.ping_timeout not set, defaulting to {self.ping_timeout}")
4746
def _populate_chain_id_metadata(self):
4847
# Conditionally add chain_id based on the colelctor type to each rpc item.
4948
if self.configuration['collector'] not in ['cardano', 'solana', 'bitcoin', 'doge', 'filecoin', 'starkware']:

0 commit comments

Comments
 (0)