jrief / django-websocket-redis

Websockets for Django applications using Redis as message queue
http://django-websocket-redis.awesto.com/
MIT License
894 stars 221 forks source link

subscribe-user and multiple browser tabs #249

Open vporton opened 6 years ago

vporton commented 6 years ago

When I open two browser tabs which wait for subscribe-user messages for the same user in both tabs, only the first opened tab receives the messages.

Sadly, our source is closed and I cannot show example code. If needed I will work on extracting testing code out of our sources.

2DKot commented 6 years ago

Do you run project in development mode? You should use separate uWSGI instance and gevent to handle many clients. http://django-websocket-redis.readthedocs.io/en/latest/running.html#django-with-websockets-for-redis-behind-nginx-using-uwsgi

twodarek commented 6 years ago

I am also experiencing this, but my cluster allows subscribe-user to occur once for a limit of TWO tabs per user. I use the example code for a user-side client, with the basic setup for a WSGI i jango.

@2DKot In my case, setting gevent in the launch config doesn't seem to help (copied below incase I didn't actually use it correctly)

In the launch script:

uwsgi --http :8001 --http-websockets --workers=2 --gevent 1000 --master --wsgi-file wsgi_websocket.py &

wsgi_websocket.py

import os
import gevent.socket
import redis.connection
redis.connection.socket = gevent.socket
os.environ.update(DJANGO_SETTINGS_MODULE='app.settings')
from ws4redis.uwsgi_runserver import uWSGIWebsocketServer
application = uWSGIWebsocketServer()