Skip to content
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

Not reattempting to connect when the first attempt failed. #503

Closed
Dwyte opened this issue Jun 8, 2020 · 1 comment
Closed

Not reattempting to connect when the first attempt failed. #503

Dwyte opened this issue Jun 8, 2020 · 1 comment
Labels

Comments

@Dwyte
Copy link

Dwyte commented Jun 8, 2020

main.py

import socketio
import asyncio
import logging

logging.basicConfig(level=logging.INFO)

loop = asyncio.get_event_loop()
sio = socketio.AsyncClient(logger=True, ssl_verify=False)

@sio.event
def connect():
    print("Client Connected")

@sio.event
def connect_error():
    print("Connection Failed.")

@sio.event
def disconnect():
    print("Client Disconnected")

async def main():
    await sio.connect("https://localhost:8080")

if __name__ == "__main__":
    loop.create_task(main())
    loop.run_forever()
    pass

The Log on HTTP version:

INFO:engineio.client:Attempting polling connection to http://localhost:8080/socket.io/?transport=polling&EIO=3
INFO:engineio.client:Polling connection accepted with {'sid': '6e1ffa1049c84e3b9f2d56fb58ab692b', 'upgrades': ['websocket'], 'pingTimeout': 60000, 'pingInterval': 25000}
INFO:socketio.client:Engine.IO connection established
INFO:engineio.client:Received packet MESSAGE data 0
INFO:engineio.client:Attempting WebSocket upgrade to ws://localhost:8080/socket.io/?transport=websocket&EIO=3
INFO:socketio.client:Namespace / is connected
Client Connected
INFO:engineio.client:WebSocket upgrade was successful
INFO:engineio.client:Sending packet PING data None
INFO:engineio.client:Received packet NOOP data None
INFO:engineio.client:Received packet PONG data None
INFO:engineio.client:Unexpected error decoding packet: "'int' object has no attribute 'encode'", aborting
INFO:engineio.client:Waiting for write loop task to end
INFO:engineio.client:Exiting write loop task
INFO:engineio.client:Waiting for ping loop task to end
INFO:engineio.client:Sending packet PING data None
INFO:engineio.client:PONG response has not been received, aborting
INFO:engineio.client:Exiting ping task
INFO:socketio.client:Engine.IO connection dropped
Client Disconnected
INFO:engineio.client:Exiting read loop task
INFO:socketio.client:Connection failed, new attempt in 3.26 seconds
INFO:engineio.client:Attempting polling connection to http://localhost:8080/socket.io/?transport=polling&EIO=3
INFO:engineio.client:HTTP GET request to http://localhost:8080/socket.io/?transport=polling&EIO=3&t=1591616760.6109302 failed with error Cannot connect to host localhost:8080 ssl:False [Connect call failed ('127.0.0.1', 8080)].

The log came from an HTTP python boilerplate server that I tested as well, but the real server I have is HTTPS on nodejs. Both had a similar results and logs.

Versions:

python:
python-engineio (3.13.0)
python-socketio (4.6.0)

nodejs:
socket.io 2.3.0

How to duplicate:

  1. Start Server
  2. Start Client
  3. Halt Server and Turn it back on.

I was mimicking if the server ever fails and comes back again would the client reconnects automatically.

Only attempts once even it should be inifinite reconnection_attempts=0. I tried putting diff number like 100, still only reattempted once.

EDIT: Added more info.

@miguelgrinberg
Copy link
Owner

I believe this has been fixed, it appears you are having the same issue reported in #417. Try upgrading your python-socketio and python-engineio packages to their latest releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants