1717from scalecodec .type_registry import load_type_registry_preset
1818from scalecodec .types import ScaleType
1919from substrateinterface .base import QueryMapResult , SubstrateInterface
20+ from websockets .exceptions import InvalidStatus
2021from websockets .sync import client as ws_client
2122
2223from bittensor .core import settings
@@ -233,6 +234,7 @@ def _get_substrate(self, force: bool = False):
233234 open_timeout = self ._connection_timeout ,
234235 max_size = 2 ** 32 ,
235236 )
237+
236238 self .substrate = SubstrateInterface (
237239 ss58_format = settings .SS58_FORMAT ,
238240 use_remote_preset = True ,
@@ -244,19 +246,26 @@ def _get_substrate(self, force: bool = False):
244246 f"Connected to { self .network } network and { self .chain_endpoint } ."
245247 )
246248
247- except ( ConnectionRefusedError , ssl . SSLError ) as error :
248- logging .error (
249- f"< red> Could not connect to< /red> < blue> { self .network } < /blue> < red> network with< /red> < blue> { self .chain_endpoint } < /blue> < red> chain endpoint.< /red> " ,
249+ except ConnectionRefusedError as error :
250+ logging .critical (
251+ f"[ red] Could not connect to[ /red] [ blue] { self .network } [ /blue] [ red] network with[ /red] [ blue] { self .chain_endpoint } [ /blue] [ red] chain endpoint.[ /red] " ,
250252 )
251253 raise ConnectionRefusedError (error .args )
252- except ssl .SSLError as e :
254+
255+ except ssl .SSLError as error :
253256 logging .critical (
254257 "SSL error occurred. To resolve this issue, run the following command in your terminal:"
255258 )
256259 logging .critical ("[blue]sudo python -m bittensor certifi[/blue]" )
257260 raise RuntimeError (
258261 "SSL configuration issue, please follow the instructions above."
259- ) from e
262+ ) from error
263+
264+ except InvalidStatus as error :
265+ logging .critical (
266+ f"[red]You have reached the limit of simultaneous connections to the server.[/red]"
267+ )
268+ raise InvalidStatus (error .response ) from error
260269
261270 @staticmethod
262271 def config () -> "Config" :
0 commit comments