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

Namespace Standard Events not firing #149

Open bp1222 opened 7 years ago

bp1222 commented 7 years ago

According to the documentation it would seem that the following

class Namespace(BaseNamespace):
    def on_connect(self):
        print('[Connected]')
    ...

socketIO = SocketIO('localhost', 8000, Namespace)
socketIO.wait(seconds=1)

ought to fire the on_connect callback for the root namespace, however I'm not seeing this behavior. I see the following outputted:

dwalker@host:/src › python client.py
DEBUG:socketIO-client:127.0.0.1:8000/socket.io [engine.io transport selected] websocket
DEBUG:socketIO-client:127.0.0.1:8000/socket.io [engine.io heartbeat reset]

However, if I change the code to use the .define() we do see the on_connect called for a given new namespace

socketIO = SocketIO('http://127.0.0.1', 8000)
socketIO.define(Namespace, '/ns')

we get the following

dwalker@host:/src › python client.py
DEBUG:socketIO-client:127.0.0.1:5000/socket.io [engine.io transport selected] websocket
DEBUG:socketIO-client:127.0.0.1:5000/socket.io [engine.io heartbeat reset]
DEBUG:socketIO-client:127.0.0.1:5000/socket.io [socket.io packet sent] 0/ns,
DEBUG:socketIO-client:127.0.0.1:5000/socket.io /ns [socket.io waiting for connection]
DEBUG:socketIO-client:127.0.0.1:5000/socket.io /ns [socket.io waiting for connection]
DEBUG:socketIO-client:127.0.0.1:5000/socket.io [socket.io packet received] b'0/ns'
[Connected]

Am I missing something with the documentation, or should the root Namesapce also be getting to the on_connect callback?

PY1CX commented 7 years ago

Same problem here. Events doesn't fire and if the computer goes out of internet it stucks in the emit. I'm trying to find a workaround for this :/

PY1CX commented 7 years ago

There is a solution for this problem: socketIO = SocketIO( _SERVER_ADRESS, _SERVER_PORT, BaseNamespace, wait_for_connection=False) At least here, It's working normally now.

mariusdotspinu commented 7 years ago

I have the same problem, whenever I emit from my server, the client's event doesn't catch the message. @PY1CX thanks for a solution , however it doesn't work in my case :|

snakeztc commented 7 years ago

Same problem here. The client can emit but never get message from other clients.

juangom commented 7 years ago

Same here. If you define a namespace with work OK.

JasXSL commented 6 years ago

Having the same issue. No matter what implementation I try it doesn't trigger. It does connect and can send messages though.

Seems to be related to the socket.io 2 fork, only packets of type 3 and 4 seem to be received I'll take it there.

wilz5363 commented 6 years ago

So, is there any viable solution/workaround for this issue?

juniiorlima commented 6 years ago

I have the same problem