fix: adjusted ping data on ping_stream, and made it so that communication agent is more robust and quick in ping communication.

ref: N25B-142
This commit is contained in:
Björn Otgaar
2025-10-30 13:07:01 +01:00
parent df6a39866b
commit af3e4ae56a
2 changed files with 6 additions and 2 deletions

View File

@@ -45,7 +45,7 @@ async def ping_stream(request: Request):
sub_socket = context.socket(zmq.SUB)
sub_socket.connect(settings.zmq_settings.internal_comm_address)
sub_socket.setsockopt(zmq.SUBSCRIBE, b"ping")
connected = True
connected = False
ping_frequency = 1 # How many seconds between ping attempts
@@ -68,7 +68,8 @@ async def ping_stream(request: Request):
logger.debug(f"Yielded new connection event in robot ping router: {str(connected)}")
yield f"data: {str(connected)}, time:{str(datetime.datetime.now().strftime("%H:%M:%S"))}\n\n"
falseJson = json.dumps(connected)
yield (f"data: {falseJson}\n\n")
return StreamingResponse(event_stream(), media_type="text/event-stream")