Skip to content

Commit 5988625

Browse files
Enable reconnection instead of stop communications
1 parent aa81b35 commit 5988625

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

nebula/core/network/connection.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ async def reconnect(self, max_retries: int = 5, delay: int = 5) -> None:
171171
except Exception as e:
172172
logging.error(f"Reconnection attempt {attempt + 1} failed: {e}")
173173
await asyncio.sleep(delay)
174-
logging.error(f"Failed to reconnect to {self.addr} after {max_retries} attempts")
174+
logging.error(f"Failed to reconnect to {self.addr} after {max_retries} attempts. Stopping connection...")
175175
await self.stop()
176176

177177
async def send(self, data: Any, pb: bool = True, encoding_type: str = "utf-8", is_compressed: bool = False) -> None:
@@ -194,7 +194,7 @@ async def send(self, data: Any, pb: bool = True, encoding_type: str = "utf-8", i
194194
await self._send_chunks(message_id, data_to_send)
195195
except Exception as e:
196196
logging.error(f"Error sending data: {e}")
197-
await self.stop()
197+
await self.reconnect()
198198

199199
def _prepare_data(self, data: Any, pb: bool, encoding_type: str) -> tuple[bytes, bytes]:
200200
if pb:
@@ -267,8 +267,6 @@ async def handle_incoming_message(self) -> None:
267267
await self.reconnect()
268268
except Exception as e:
269269
logging.error(f"Error handling incoming message: {e}")
270-
finally:
271-
await self.stop()
272270

273271
async def _read_exactly(self, num_bytes: int, max_retries: int = 3) -> bytes:
274272
data = b""

0 commit comments

Comments
 (0)