-
-
Notifications
You must be signed in to change notification settings - Fork 596
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
Attribute error on sio.wait() #417
Comments
What server are you connecting to? It seems this client is receiving unexpected data from it. |
I'm using a python socket-io server too. This is the only client application that has issues, and I think it only happens when there's too high load on the event loop. |
Can you provide a server and client I can use to reproduce this? |
Hi, I also have the exact same error. The error happens when the client is connected to the server and you close the server (simulating a disconnect). Looking at the wait method is asyncio_client.py, I can see the reconnect task should be started but it does not... Expected result: When server disconnect, the client try to reconnect. Here is the client code: import asyncio
import time
import socketio
loop = asyncio.get_event_loop()
sio = socketio.AsyncClient()
start_timer = None
@sio.event
async def connect():
print('connected to server')
async def start_server():
try:
await sio.connect('http://localhost:8080')
await sio.wait()
except socketio.exceptions.ConnectionError:
print("Cannot connect to server")
if __name__ == '__main__':
loop.run_until_complete(start_server()) You can use any server example |
@thoquine I cannot reproduce using the server example from the Flask-SocketIO repository. When I Ctrl-C the server the client remains waiting, and as soon as I start a new server it reconnects. |
@miguelgrinberg I think I found the problem. When I kill the server with ctrl+c I got the error on the client side. But when I simply kill the terminal running the server, the client try to reconnect as expected. I'm using the aiohttp version of the server. Any idea why it's doing this? Thanks for your help! |
@thoquine Thanks, what I was missing was that the server had to be aiohttp, the others do not reproduce this problem. The aiohttp web server is indeed sending a number right before ending the connection. I still don't know if the aiohttp server has the problem, or the websocket client that I'm using. This number is a code that indicates that the connection is ending, but it is unclear why it is being sent or received as a normal message and not as connection metadata. Need to investigate this in more detail. |
@thoquine can I ask you to install the master branch for the python-engineio repository and retest? Thanks! |
@miguelgrinberg Yeah sure! I will do it this week and come back with the results. |
I hit this issue as well (can reproduce it reliably in my environment). I will try out the master branch of python-engineio repo.. Edit: Tested and works In case it helps anyone else coming here. The problem in my case was due to asyncio client calling a "subprocess.popen / p.communicate()" that took about 60 seconds to complete. The client was disconnected after the subprocess was complete and resulted in this issue. I had to move over to async version of subprocess. |
I have been struggling to keep my socket connected in an application. Since this program is already running it's own loop, I have a background task that attempts to connect to the socket server, until it does. Initially, it was working fine, but as load increased, it started dropping the connection to the socket and not reconnecting (not sending the disconnected event either).
So I proceeded to add a
sio.wait()
right after connect, hoping that this would keep my connection alive, but now it is raising exceptions after some time online.The text was updated successfully, but these errors were encountered: