django-websocket-redis icon indicating copy to clipboard operation
django-websocket-redis copied to clipboard

subscribe-user and multiple browser tabs

Open vporton opened this issue 8 years ago • 2 comments

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.

vporton avatar Nov 04 '17 23:11 vporton

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

2DKot avatar Dec 26 '17 10:12 2DKot

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()

twodarek avatar Dec 29 '17 05:12 twodarek