Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/SK-1048 | Logs about grpc stream and heartbeat back online #707

Merged
merged 1 commit into from
Sep 23, 2024
Merged
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
7 changes: 7 additions & 0 deletions fedn/network/clients/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,13 @@ def _listen_to_task_stream(self):
r.sender.client_id = self.id
# Add client to metadata
self._add_grpc_metadata("client", self.name)
status_code = None

while self._connected:
try:
if status_code == grpc.StatusCode.UNAVAILABLE:
logger.info("GRPC TaskStream: server available again.")
status_code = None
for request in self.combinerStub.TaskStream(r, metadata=self.metadata):
if request:
logger.debug("Received model update request from combiner: {}.".format(request))
Expand Down Expand Up @@ -444,6 +448,7 @@ def _listen_to_task_stream(self):
logger.warning("GRPC TaskStream: server unavailable during model update request stream. Retrying.")
# Retry after a delay
time.sleep(5)
continue
if status_code == grpc.StatusCode.UNAUTHENTICATED:
details = e.details()
if details == "Token expired":
Expand Down Expand Up @@ -750,6 +755,8 @@ def _send_heartbeat(self, update_frequency=2.0):
heartbeat = fedn.Heartbeat(sender=fedn.Client(name=self.name, role=fedn.WORKER, client_id=self.id))
try:
self.connectorStub.SendHeartbeat(heartbeat, metadata=self.metadata)
if self._missed_heartbeat > 0:
logger.info("GRPC heartbeat: combiner available again after {} missed heartbeats.".format(self._missed_heartbeat))
self._missed_heartbeat = 0
except grpc.RpcError as e:
status_code = e.code()
Expand Down
Loading