socketIO-client icon indicating copy to clipboard operation
socketIO-client copied to clipboard

Namespace Standard Events not firing

Open bp1222 opened this issue 7 years ago • 8 comments

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?

bp1222 avatar Mar 06 '17 21:03 bp1222

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 avatar Mar 20 '17 05:03 PY1CX

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.

PY1CX avatar Mar 22 '17 16:03 PY1CX

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 :|

mariusdotspinu avatar Mar 29 '17 20:03 mariusdotspinu

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

snakeztc avatar May 05 '17 02:05 snakeztc

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

juangom avatar May 31 '17 03:05 juangom

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.

JasXSL avatar Feb 20 '18 20:02 JasXSL

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

wilz5363 avatar May 15 '18 06:05 wilz5363

I have the same problem

juniiorlima avatar Aug 02 '18 01:08 juniiorlima