Hi, I've done something ugly right now since it is just a proof of concept for the moment. I considered using usgi queue or the shared area, it would be nice to use the websocket_send_from_sharedarea, but I felt I was overcomplicating things even before I got a first version working.
I read the article about offloading websokets, if I understood correctly I the idea is to forward connections to another uwsgi server, correct? So I would need to run two uwsgi instances, the first in normal mode, with workers and one process for each request and the second in async mode, that's the idea? So what's the offload-threads parameter for? BTW, if I wanted to make a feature request, is this the right place? Are those welcomed at all? How does this work? I believe that if the websocket_send and websocket_send_binary could receive as an optional parameter the ws fd it would greatly help my life, in this way one thread could send a message to another ws. Thanks Avraham On Mon, Jan 9, 2017 at 10:39 PM, Avraham Serour <[email protected]> wrote: > Hi, > > I still need to run it somewhere, are you suggesting to run it together > with the websocket handling? So it would run in every offload thread? > > In any case, once I have pulled a message from redis I still need to know > how to send it to the correct websocket. > > Logically I would create a different queue for each websocket, so each > websocket handler can listen to its own specific queue, and every message > received is sent to the client. > But the protocol specification defines one queue name websocket.receive > and inside each message it has an id for the reply_channel which I should > associate with a socket. > So a consumer would need to get a message from redis, parse and identify > which to socket to send the message. > > Currently the application decides the backend it wants to use, so I can't > use the redis client of my choice since what I'm trying to implement is the > protocol layer. > Initially I wanted to use 'uwsgi.wait_fd_read(redis_fd)', but I couldn't > figure how to get the fd from the redis the application is using, also I > should support different backends the application is using, maybe I can > have one implementation using the official API and one optimized using > wait_fd_read if possible. > > So the API I have is basically a function channel_layer.receive_many(), > even the reference implementation calls this in a closed loop with a > sleep(0.05). Can I have something like this running on a separate thread on > uwsgi? > > Thanks > Avraham > > > On Mon, Jan 9, 2017 at 10:19 PM, Mikko Ohtamaa <[email protected]> > wrote: > >> >> >> On 9 January 2017 at 14:17, Avraham Serour <[email protected]> wrote: >> >>> I mean from redis, if the application decides to send a message to a >>> user it is stored in the broker (right now in my first version I'm using >>> redis), I need a consumer to check if there are messages available and >>> direct them each to the correct socket. >>> >> >> You can use async Redis driver https://github.com/jonathansle >> nders/asyncio-redis#pubsub-example >> >> >> _______________________________________________ >> uWSGI mailing list >> [email protected] >> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi >> >> >
_______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
