File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 508, in handle_one_response
self.run_application()
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/geventwebsocket/handler.py", line 88, in run_application
return super(WebSocketHandler, self).run_application()
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 494, in run_application
self.result = self.application(self.environ, self.start_response)
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/flask/app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/flask_socketio/init.py", line 27, in call
raise RuntimeError('You need to use a gevent-socketio server.')
RuntimeError: You need to use a gevent-socketio server.
{'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.5',
'HTTP_CACHE_CONTROL': 'no-cache',
'HTTP_CONNECTION': 'upgrade',
'HTTP_COOKIE': 'user-id=BYH0IY80VM9RD2ZOWKLR1',
'HTTP_HOST': '127.0.0.1:8000',
'HTTP_ORIGIN': '[MANUALLY REMOVED FOR PRIVACY REASONS]',
'HTTP_PRAGMA': 'no-cache',
'HTTP_SEC_WEBSOCKET_KEY': 'ekUWDrWk7/SS5pDdOPExMA==',
'HTTP_SEC_WEBSOCKET_VERSION': '13',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0',
'HTTP_VIA': '1.1 localhost.localdomain 80F42A05',
'PATH_INFO': '/socket.io/1/websocket/613508800898',
'QUERY_STRING': '',
'RAW_URI': '/socket.io/1/websocket/613508800898',
'REMOTE_ADDR': '127.0.0.1',
'REMOTE_PORT': '56014',
'REQUEST_METHOD': 'GET',
'SCRIPT_NAME': '',
'SERVER_NAME': 'localhost',
'SERVER_PORT': '8000',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SOFTWARE': 'gevent/1.0 Python/2.7',
'gunicorn.sock': <socket at 0x7f8fc0b89e90 fileno=12 sock=127.0.0.1:8000 peer=127.0.0.1:56014>,
'wsgi.errors': <open file '', mode 'w' at 0x7f8fc53c01e0>,
'wsgi.input': <gevent.pywsgi.Input object at 0x7f8fc0b37f90>,
'wsgi.multiprocess': False,
'wsgi.multithread': False,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)} failed with RuntimeError
Traceback (most recent call last):
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/gevent/greenlet.py", line 327, in run
result = self._run(_self.args, *_self.kwargs)
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/socketio/server.py", line 124, in handle
handler.handle()
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 184, in handle
result = self.handle_one_request()
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 321, in handle_one_request
self.handle_one_response()
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/socketio/handler.py", line 170, in handle_one_response
self.transport.do_exchange(socket, request_method)
File "/home/ubuntu/bachelor-thesis/crowd-tracker/venv/local/lib/python2.7/site-packages/socketio/transports.py", line 241, in do_exchange
websocket = self.handler.environ['wsgi.websocket']
KeyError: 'wsgi.websocket'
<Greenlet at 0x7f8fc1918410: <bound method SocketIOServer.handle of <SocketIOServer at 0x7f8fc0b89f90 fileno=5 address=127.0.0.1:8000>>(<socket at 0x7f8fc0b89e90 fileno=[Errno 9] Bad fil, ('127.0.0.1', 56014))> failed with KeyError
I use both a Gevent worker with gunicorn (--worker-class socketio.sgunicorn.GeventSocketIOWorker app:app -w 1) as well as the 0.9.16 socket io library. This error is also not consistent - one of my clients caused it. I can't reproduce it.
Gunicorn runs behind an nginx proxy.
Since this is a critical error for my application and we have a deadly deadline coming quick help is much appreciated.