invisibleroads / socketIO-client

A socket.io client library for Python
http://pypi.python.org/pypi/socketIO-client
MIT License
447 stars 205 forks source link

what to do if connection is rejected #168

Open liushapku opened 7 years ago

liushapku commented 7 years ago

I tried to use this client to connect to a flask-socketio server. On the server side, I deliberately rejected the connection by returning False from the @socketio.on('connect') handler.

Then the client will block at this line and repeatedly request for new connection

socketIO = SocketIO('localhost', 8000, LoggingNamespace)

Is there any event like connection_rejected?

AmazingRaise commented 6 years ago

2017-11-10 10:21:18,559 /socket.io [engine.io transport selected] websocket 2017-11-10 10:21:18,561 /socket.io [engine.io heartbeat reset] 2017-11-10 10:21:18,562 /socket.io [socket.io packet sent] 0/agent, 2017-11-10 10:21:18,563 /socket.io /agent [socket.io waiting for connection] 2017-11-10 10:21:18,612 /socket.io [socket.io packet received] 0 2017-11-10 10:21:18,613 /socket.io [socket.io connected] 2017-11-10 10:21:18,613 /socket.io /agent [socket.io waiting for connection] 2017-11-10 10:21:19,139 /socket.io /agent [socket.io waiting for connection] 2017-11-10 10:21:19,140 /socket.io /agent [socket.io waiting for connection] 2017-11-10 10:21:20,145 /socket.io /agent [socket.io waiting for connection] 2017-11-10 10:21:21,148 /socket.io /agent [socket.io waiting for connection] 2017-11-10 10:21:21,941 /socket.io [socket.io packet received] 1/agent, 2017-11-10 10:21:21,941 disconnect

check if really disconnect。if so, when callback, you can raise Exception to stop running.