gevent-socketio icon indicating copy to clipboard operation
gevent-socketio copied to clipboard

I see this ocassionally on my log files. Not sure why this can occur.

Open vivekfantain opened this issue 10 years ago • 5 comments

It would be fairly easy to check for the existence of the key but I wonder how this can happen in the first place.

INFO:geventwebsocket.handler:127.0.0.1 - - [2014-04-04 15:52:41] "GET /rt/1/websocket/165808242674 HTTP/1.1" 400 190 0.002412
Traceback (most recent call last):
  File "/home/fantain/.environments/fantaindev/local/lib/python2.7/site-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "/home/fantain/.environments/fantaindev/local/lib/python2.7/site-packages/socketio/server.py", line 124, in handle
    handler.handle()
  File "/home/fantain/.environments/fantaindev/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 184, in handle
    result = self.handle_one_request()
  File "/home/fantain/.environments/fantaindev/local/lib/python2.7/site-packages/gevent/pywsgi.py", line 321, in handle_one_request
    self.handle_one_response()
  File "/home/fantain/.environments/fantaindev/local/lib/python2.7/site-packages/socketio/handler.py", line 170, in handle_one_response
    self.transport.do_exchange(socket, request_method)
  File "/home/fantain/.environments/fantaindev/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 0x2e50050: <bound method SocketIOServer.handle of <SocketIOServer at 0x2850690 fileno=15 address=127.0.0.1:8082>>(<socket at 0x30e7990 fileno=[Errno 9] Bad file des, ('127.0.0.1', 60664))> failed with KeyError

vivekfantain avatar Apr 04 '14 11:04 vivekfantain

I assumed it might be because the call to add the key into the dictionary is async so when you go to look for it, the process might not have finished. To be honest though, I'm not very confident in that answer. Perhaps, wrap it in a try-except and see if waiting for an extra second does anything? Bad fix, but that can help verify the conjecture?

abhikalakuntla avatar Apr 20 '14 05:04 abhikalakuntla

Abhi - I am running it on gevent which is co-operative threading so this is probably not correct.

vivekfantain avatar Apr 21 '14 02:04 vivekfantain

Hmm - Yeah not too sure. Could be possibly this reason?: http://gevent-socketio.readthedocs.org/en/latest/namespace.html#socketio.namespace.BaseNamespace.emit

abhikalakuntla avatar Apr 21 '14 04:04 abhikalakuntla

I am experiencing this error when the page is accessed from behind a proxy, like e.g. in an office or hotel. Would this make sense...?

fzumstein avatar Feb 14 '15 16:02 fzumstein

This is a later version of client socketio-js. (I've also seen this when googlebot visits :) )

kennedyshead avatar Mar 19 '16 08:03 kennedyshead