You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is, after a certain number of messages are sent from the server, the client cannot receive the messages.
I created a websockets server. I called the send_node_data function in the main thread to send a message to the client. At first, everything runs well. The strange thing is that after I sent the message to the client about 700 times in a row, the client no longer received the message sent anymore. At the same time, the server executed the send method without throwing any exception. It just continued to execute normally.
This is my code, I created a new websockets server.
def __start_thread(self):
debug_thread = threading.Thread(target=self.__debug_serve, daemon=True)
debug_thread.setName("websocket_thread")
debug_thread.start()
def __debug_serve(self):
try:
asyncio.run(self.__start_server())
except Exception as e:
LOG.error("server has error: ", e)
async def __start_server(self):
self.server = websockets.serve(self.__start,
"127.0.0.1",
self.port,
ping_interval=None,
max_size=None)
async with self.server:
await asyncio.Future() # run forever
async def __start(self, client, path):
if self.client is not None:
return
self.client = client
await self.recv_start_request()
self.lock.set()
try:
await self.recv_other_request()
except websockets.exceptions.ConnectionClosed as e:
# The client is disconnected and the sys exception is thrown.
self.lock.set()
LOG.error("client is closed")
self._async_raise(threading.main_thread().ident,
SystemExit)
And I'm sending a message to the client via send_node_data.
The problem is, after a certain number of messages are sent from the server, the client cannot receive the messages.
I created a websockets server. I called the send_node_data function in the main thread to send a message to the client. At first, everything runs well. The strange thing is that after I sent the message to the client about 700 times in a row, the client no longer received the message sent anymore. At the same time, the server executed the send method without throwing any exception. It just continued to execute normally.
This is my code, I created a new websockets server.
And I'm sending a message to the client via send_node_data.
I tried adding a delay after sending the message with await asyncio.sleep, but that didn't work either.
The text was updated successfully, but these errors were encountered: