Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _get_substrate(self):
"""Establishes a connection to the Substrate node using configured parameters."""
try:
# Set up params.
if not self.websocket:
if self.websocket is None or self.websocket.close_code is not None:
self.websocket = ws_client.connect(
self.chain_endpoint,
open_timeout=self._connection_timeout,
Expand Down
4 changes: 2 additions & 2 deletions bittensor/utils/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import netaddr
import requests
from retry import retry
from websocket import WebSocketConnectionClosedException
from websockets.exceptions import ConnectionClosed

from bittensor.utils.btlogging import logging

Expand Down Expand Up @@ -193,7 +193,7 @@ def wrapper(self, *args, **kwargs):

try:
return func(self, *args, **kwargs)
except WebSocketConnectionClosedException:
except ConnectionClosed:
logging.console.warning(
"WebSocket connection closed. Attempting to reconnect 5 times..."
)
Expand Down
2 changes: 2 additions & 0 deletions tests/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def get_mock_neuron_by_uid(uid: int, **kwargs) -> NeuronInfo:


class FakeWebsocket(ClientConnection):
close_code = None

def __init__(self, *args, seed, **kwargs):
protocol = ClientProtocol(parse_uri("ws://127.0.0.1:9945"))
super().__init__(socket=None, protocol=protocol, **kwargs)
Expand Down