fix: wait for req socket send to make sure we dont stay stuck - if there's no... #23

Merged
9828273 merged 19 commits from feat/cb2ui-robot-connections into dev 2025-11-18 12:24:15 +00:00
2 changed files with 6 additions and 2 deletions
Showing only changes of commit af3e4ae56a - Show all commits

View File

@@ -86,6 +86,9 @@ class RICommunicationAgent(Agent):
# See what endpoint we received
match message["endpoint"]:
case "ping":
topic = b"ping"
data = json.dumps(True).encode()
await self.agent._pub_socket.send_multipart([topic, data])
await asyncio.sleep(1)
case _:
logger.info(

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")