Comments (4)
I've run into this issue with Apache's mod_proxy too. However, are you sure that your websocket will even work via Nginx's proxy module? Websockets require full-duplex communication, and I suspect that most proxies only support a single request/response pair.
from gevent-socketio.
Exactly. Nginx doesn't forward all the headers (because it seems Websocket isn't fully HTTP/1.1 compliant) and it doesn't allow for full negotiation of the websocket. Thus, 'wsgi.websocket' isn't inserted in the environment (that's where you get your KeyError). Also, I don't think Nginx is ready to do full-duplex either.
I know it is possible to configure HAProxy to forward everything to the gevent server, so I would suggest looking in that direction.
Since this ticket isn't related to a bug in gevent-socket, I'm going to close it.
Hope this helps.
from gevent-socketio.
Nginx supports websockets as you can see here. I've tested it in front of a simple Node.JS server and with Socket.io client. It worked!
Now, in a project i'm currently working on, I'm running Gunicorn + gevent-socketio as recommended in the docs. No problem there. However I've tried to set Nginx up with SSL enabled, like this:
server { listen 443; server_name events.hostname; ssl on; ssl_certificate /path/to/x.crt; ssl_certificate_key /path/to/x.key; ssl_session_cache shared:SSL:10m; ssl_session_timeout 5m; location / { proxy_pass http://127.0.0.1:8000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_redirect off; } }
Without success.
Every time my Socket.io client tries to connect, it receives a 500 status code due to the KeyError: 'wsgi.websocket'
exception. I guessed the "Upgrade" header was missing, which I find weird.
So i changed the configuration a little bit and set the header manually proxy_set_header Upgrade "websocket"
. As a result the exception is raised no-more. However after a while i get this error Error during WebSocket handshake: 'Upgrade' header is missing
on my javascript console.
Dispite this problem may not be related to a bug in gevent-socket, I would appreciate any help. Any ideias of what might be wrong? Am I missing anything?
from gevent-socketio.
I use Gunicorn + nginx1.4.1 ,and add my nginx.conf
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8082/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
when running the code, I keep get this error " KeyError: 'wsgi.websocket' " ,but application stil work and it's little bit slow when trying to connect websocket .
after googling then i'm installing nginx-full and my problem solved ,hope this can help.
from gevent-socketio.
Related Issues (20)
- How to broadcast data to a room (of socket io) when the server receives data from somewhere else (not using socket io)
- headers use integer for Access-Control-Max-Age HOT 1
- GeventSocketIOWorker fails to boot when used with gunicorn and ssl flags
- WebSocket is closed before the connection is established. HOT 1
- gevent UnicodeError HOT 3
- django.utils.importlib is removed in Django 1.9 HOT 1
- Merge working tests MR and ask people to rebase
- About renaming the "socketio" library name
- BaseNamespace.session
- SSL Error
- Django 1.10 Support
- django example won't install
- WebSocketError: Received "Socket is dead".
- My chat room sometimes the user sends the text all become?????
- how to run socket.io chat app from two different ports
- Tag 668d11edbd62052cde1583be1e1d0512c930f16d as 0.3.6?
- Release 0.3.7 with post-0.3.6 fixes? HOT 1
- Is it possible to use gevent-socketio as a socket.io client? HOT 1
- KeyError: 'socketio' in socketio_manager
- Version compatability issue on Executing Tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gevent-socketio.