Re: [uWSGI] getting websockets to work with emperor/vassals and nginx

2017-07-07 Thread Andrew Fischer
Harry,

Now, as far as I can tell, the assumption in the examples is that your
> worker will be tied up in a while True: loop handling requests, right?  so
> the next thing i have to think about is the concurrency model...  am taking
> a look at https://github.com/unbit/uwsgi/blob/master/tests/
> websockets_chat_async.py.


That is correct. We use code modeled off of that same example and so far it
has worked very well.

Also good find with your loadbalancer issue. Almost every time I had a
problem with websockets it seems to have ended up being the loadbalancer.

Best of luck,
-Andrew


Andrew Fischer
Apastron Co
903 1st ST N Hopkins, MN
952-373-1024
___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] getting websockets to work with emperor/vassals and nginx

2017-07-07 Thread Harry Percival
Got it working!  Sure enough, I needed the connection/header upgrade 
stanzas on the loadbalancer's proxy_pass config, but i didn't need to 
make any changes to the actual web server nginx uwsgi_pass config.  Have 
updated the PR.


Now, as far as I can tell, the assumption in the examples is that your 
worker will be tied up in a while True: loop handling requests, right?  
so the next thing i have to think about is the concurrency model...  am 
taking a look at 
https://github.com/unbit/uwsgi/blob/master/tests/websockets_chat_async.py.


HP


On 07/07/17 12:48, Harry Percival wrote:
Or maybe the  uwsgi_pass  nginx proxy *does* handle websockets, but 
the standard proxy_pass one does not?  so i just need to fix the 
config on my loadbalancer (which uses proxy_pass) but not the one on 
my web server?  will try that...



On 07/07/17 12:45, Harry Percival wrote:
OK I *think* the docs are incorrect -- they currently say that nginx 
just works out of the box, but as far as I can tell that's incorrect, 
you need to explicitly get it to proxy the Upgrade and Connection 
headers:


https://nginx.org/en/docs/http/websocket.html


here's a PR to fix the docs (if indeed I am correct!  it's still not 
working. https://github.com/unbit/uwsgi-docs/pull/362)



rgds,
Harry & the PythonAnywhere team




On 07/07/17 11:49, Harry Percival wrote:

Hey there uwsgi friends,


Thought I'd do a little experiment to see if we can get websockets 
working in our infrastructure.  here's the setup:



* loadbalancer:  nginx forwards http requests to correct web server 
based on domain name


* web server:  nginx listens on port 80, proxies to uwsgi via 
"uwsgi_pass" to a unix socket


* uwsgi emperor

* uwsgi vassals: listen on correct socket


all works fine for standard WSGI HTTP/S stuff.  now I'd like to see 
if websockets will work.



It's a bit hard to tell from the documentation whether things should 
"just work" already, or whether I need to set up additional routing 
in nginx? https://uwsgi-docs.readthedocs.io/en/latest/WebSockets.html



currently I'm seeing uwsgi.websocket_handshake()  seems to work ok, 
but uwsgi.websocket_recv() is hanging/failing with an OSError: 
unable to receive websocket message


uwsgi --version 2.0.14

nginx version: openresty/1.9.15.1



cheers all!

Harry.



___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi




___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi




___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


--
Harry Percival
Developer
ha...@pythonanywhere.com

PythonAnywhere - a fully browser-based Python development and hosting 
environment


PythonAnywhere LLP
17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79
Registered in England and Wales as company number OC378414.
Registered address: 28 Ely Place, 3rd Floor, London EC1N 6TD, UK

___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] getting websockets to work with emperor/vassals and nginx

2017-07-07 Thread Harry Percival
Or maybe the  uwsgi_pass  nginx proxy *does* handle websockets, but the 
standard proxy_pass one does not?  so i just need to fix the config on 
my loadbalancer (which uses proxy_pass) but not the one on my web 
server?  will try that...



On 07/07/17 12:45, Harry Percival wrote:
OK I *think* the docs are incorrect -- they currently say that nginx 
just works out of the box, but as far as I can tell that's incorrect, 
you need to explicitly get it to proxy the Upgrade and Connection 
headers:


https://nginx.org/en/docs/http/websocket.html


here's a PR to fix the docs (if indeed I am correct!  it's still not 
working. https://github.com/unbit/uwsgi-docs/pull/362)



rgds,
Harry & the PythonAnywhere team




On 07/07/17 11:49, Harry Percival wrote:

Hey there uwsgi friends,


Thought I'd do a little experiment to see if we can get websockets 
working in our infrastructure.  here's the setup:



* loadbalancer:  nginx forwards http requests to correct web server 
based on domain name


* web server:  nginx listens on port 80, proxies to uwsgi via 
"uwsgi_pass" to a unix socket


* uwsgi emperor

* uwsgi vassals: listen on correct socket


all works fine for standard WSGI HTTP/S stuff.  now I'd like to see 
if websockets will work.



It's a bit hard to tell from the documentation whether things should 
"just work" already, or whether I need to set up additional routing 
in nginx? https://uwsgi-docs.readthedocs.io/en/latest/WebSockets.html



currently I'm seeing uwsgi.websocket_handshake()  seems to work ok, 
but uwsgi.websocket_recv() is hanging/failing with an OSError: unable 
to receive websocket message


uwsgi --version 2.0.14

nginx version: openresty/1.9.15.1



cheers all!

Harry.



___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi




___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


--
Harry Percival
Developer
ha...@pythonanywhere.com

PythonAnywhere - a fully browser-based Python development and hosting 
environment


PythonAnywhere LLP
17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79
Registered in England and Wales as company number OC378414.
Registered address: 28 Ely Place, 3rd Floor, London EC1N 6TD, UK

___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] getting websockets to work with emperor/vassals and nginx

2017-07-07 Thread Harry Percival
OK I *think* the docs are incorrect -- they currently say that nginx 
just works out of the box, but as far as I can tell that's incorrect, 
you need to explicitly get it to proxy the Upgrade and Connection headers:


https://nginx.org/en/docs/http/websocket.html


here's a PR to fix the docs (if indeed I am correct!  it's still not 
working. https://github.com/unbit/uwsgi-docs/pull/362)



rgds,
Harry & the PythonAnywhere team




On 07/07/17 11:49, Harry Percival wrote:

Hey there uwsgi friends,


Thought I'd do a little experiment to see if we can get websockets 
working in our infrastructure.  here's the setup:



* loadbalancer:  nginx forwards http requests to correct web server 
based on domain name


* web server:  nginx listens on port 80, proxies to uwsgi via 
"uwsgi_pass" to a unix socket


* uwsgi emperor

* uwsgi vassals: listen on correct socket


all works fine for standard WSGI HTTP/S stuff.  now I'd like to see if 
websockets will work.



It's a bit hard to tell from the documentation whether things should 
"just work" already, or whether I need to set up additional routing in 
nginx? https://uwsgi-docs.readthedocs.io/en/latest/WebSockets.html



currently I'm seeing uwsgi.websocket_handshake()  seems to work ok, 
but uwsgi.websocket_recv() is hanging/failing with an OSError: unable 
to receive websocket message


uwsgi --version 2.0.14

nginx version: openresty/1.9.15.1



cheers all!

Harry.



___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


--
Harry Percival
Developer
ha...@pythonanywhere.com

PythonAnywhere - a fully browser-based Python development and hosting 
environment


PythonAnywhere LLP
17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79
Registered in England and Wales as company number OC378414.
Registered address: 28 Ely Place, 3rd Floor, London EC1N 6TD, UK

___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


[uWSGI] getting websockets to work with emperor/vassals and nginx

2017-07-07 Thread Harry Percival

Hey there uwsgi friends,


Thought I'd do a little experiment to see if we can get websockets 
working in our infrastructure.  here's the setup:



* loadbalancer:  nginx forwards http requests to correct web server 
based on domain name


* web server:  nginx listens on port 80, proxies to uwsgi via 
"uwsgi_pass" to a unix socket


* uwsgi emperor

* uwsgi vassals: listen on correct socket


all works fine for standard WSGI HTTP/S stuff.  now I'd like to see if 
websockets will work.



It's a bit hard to tell from the documentation whether things should 
"just work" already, or whether I need to set up additional routing in 
nginx? https://uwsgi-docs.readthedocs.io/en/latest/WebSockets.html



currently I'm seeing uwsgi.websocket_handshake()  seems to work ok, but 
uwsgi.websocket_recv() is hanging/failing with an OSError: unable to 
receive websocket message


uwsgi --version 2.0.14

nginx version: openresty/1.9.15.1



cheers all!

Harry.

--
Harry Percival
Developer
ha...@pythonanywhere.com

PythonAnywhere - a fully browser-based Python development and hosting 
environment


PythonAnywhere LLP
17a Clerkenwell Road, London EC1M 5RD, UK
VAT No.: GB 893 5643 79
Registered in England and Wales as company number OC378414.
Registered address: 28 Ely Place, 3rd Floor, London EC1N 6TD, UK

___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi