-
-
Notifications
You must be signed in to change notification settings - Fork 583
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
socketio.Client() keep connection, but socketio.AsyncClient() does not #324
Comments
Can you get logs from the case that disconnects? Add |
After adding |
According to the log, the WebSocket connection was interrupted:
This makes the client attempt a reconnection, which in your case succeeded. I'm not sure why the disconnection occurs, this is reported by the websocket library so it's not being done by this package. Maybe you should see if you can get logs from the server that show more information. |
The problem can be ascribed to the async websockets library (https://github.com/aaugustin/websockets). And I found the async websocket client in aiohttp library (https://github.com/aio-libs/aiohttp) works well. So, I hope your team can make a substitution. Maybe this is a solution. |
Same problem with socketio.AsyncClient(). client connects and maintain the connection for a short period of time, followed by disconnection then connection retry. |
I will see if replacing the websocket client with the one in aiohttp addresses this problem. |
Hi I am facing the same issue of AsyncClient being unable to hold the connection. I enabled logging to check what is going wrong and I see the following error after an emit.
after that it successfully reconnects. I am running 3 clients in parallel and mostly they all reconnect successfully, but if they can't they show the following error:
|
@secretlyvogon there is an open issue for this: #417. Hopefully will have a solution in the next few days. |
@miguelgrinberg as per your suggestion in #417 I installed the master branch and retested, but I am still getting the same error I mentioned above. |
@secretlyvogon did you install the master branch of this repo, or python-engineio? The fix is in the engineio repo, not here. |
I installed both from their respective master branches, and the error is still present. I will give you a little more context on what my code is doing and where exactly it is getting stuck. On the server-side, I have defined an async coroutine, which communicates with the connected nodes. The clients receive the data, perform their functions, send an emit back to the server, and wait. The server collects data sent by each client. Once all the emits are collected, the server calls that coroutine again. Thus, forming a loop. The first iteration of this loop executes properly, and the updates are collected as expected. However, right when the coroutine is called, the code seems to act oddly at the server end. By the time the coroutine emits, the clients are disconnected, and the following appears on the server-side log:
I have already included the client side logs above. |
@secretlyvogon isn't this a different problem though? You indicated that you were getting this one:
|
You are right. I am sorry for getting it confused. I was earlier getting that specific error but after installing the fix it went away. However, I am still facing some difficulty with making AsyncClient retain a connection to the Server. Should I create a new issue with all the details I have included here? |
@secretlyvogon this is likely a blocking issue on your side. The "client is gone" error happens when the regular ping/pong packets are interrupted. This can be because your client blocks and fails to send a ping at the right interval, or because your server blocks and is unable to process the pings in a timely manner. If you are using asyncio only on the server, then I would suspect that side more. If you are also using asyncio on the clients, then the blockage can be in the clients or the server. |
@miguelgrinberg Thank you for your suggestions. I was using async on both sides, so I tried with a regular client instead, and the results were the same. I feel like the issue is with the server itself. I am creating a new issue specific for my error as I feel any further discussion will not be relevant to this particular issue. |
I want to maintain a long connection, since I subscribe some topics.
When I use socketio.Client() as a client, it do as what I expect.
However, when I use socketio.AsyncClient(), it disconnect after a while maybe 1 min.
I want a asynchorous client, can anyone help me?
following are the codes
def run_sync_socketio(url=URL):
async def run_socketio(url=URL):
The text was updated successfully, but these errors were encountered: