django-socketio icon indicating copy to clipboard operation
django-socketio copied to clipboard

None of the signals in django_socketio.events fire, ever

Open ghost opened this issue 12 years ago • 1 comments

I've setup the libraries as instructed (installed the Ubuntu dependencies, installed django_socketio via PIP, added in the URLconf, put django_socketio into my settings.py's INSTALLED_APPS and run manage.py collectstatic). I'm not a Django notice and I've worked with socket.io before, but I'm utterly stumped!

Client-side things seem to be OK: a socket connection is established and the connect event is called; same for `disconnect, however no events fire at all on the server side.

In my models.py file, I've hooked up a function to the on_connect, on_subscribe and on_message events and none of them run (I've discovered this by setting up logging. A log entry is written and output to the console that confirms the code is being run that hooks up the events, but nothing ever happens when the events take place).

Is this an issue with latter versions of the Websockets protocol as mentioned in your docs? I'm running the socket server as sudo (tried in daemon and shell mode), but I get nothing either way.

Any ideas? Thanks!

ghost avatar Apr 09 '13 15:04 ghost

I've had the same problem. I believe the problem is a bug in django-socketio when there isn't a channel supplied to the decorator.

In views.py Line 38: https://github.com/stephenmcd/django-socketio/blob/master/django_socketio/views.py#L38 The socket subscribes to a channel and then calls the on_subscribe callback handler. The problem is that in events.py on Line 65: https://github.com/stephenmcd/django-socketio/blob/master/django_socketio/events.py#L65 there is a check not socket.channels. Well, we just subscribed to a channel, so that will always return False. If there isn't a channel pattern given ( i.e. the default decorator ), then no_channel will always be False and the handler will never get called at Line 71, events.py. I'm really not even certain that the no_channel variable needs to be there. It seems to me that the check for socket.channel comes later on anyway on Line 69 in events.py.

frenchtoast747 avatar Jul 02 '13 13:07 frenchtoast747