All, Jeffrey Gelens,
I am trying to get gevent-websocket to work. I cloned the rep,
installed and tried the test.py as well as the code below (taken from
http://www.gelens.org/code/gevent-websocket/):
from gevent import pywsgi
from geventwebsocket.handler import WebSocketHandler
def websocket_app(environ, start_response):
# if environ["PATH_INFO"] == '/echo':
if True:
ws = environ["wsgi.websocket"]
message = ws.wait()
ws.send(message)
server = pywsgi.WSGIServer(('127.0.0.1', 8000), websocket_app,
handler_class=WebSocketHandler)
server.serve_forever()
As a client I am using:
http://websocket.org/echo.html
With the location set to:
ws://localhost:8000
When I try to connect, python throws errors like:
python websocket_test.py
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent-0.13.6-py2.7-
linux-i686.egg/gevent/pywsgi.py", line 438, in handle_one_response
self.run_application()
File "/usr/local/lib/python2.7/dist-packages/gevent_websocket-0.2.2-
py2.7.egg/geventwebsocket/handler.py", line 36, in run_application
if self.websocket:
AttributeError: 'WebSocketHandler' object has no attribute 'websocket'
<WSGIServer fileno=3 address=
127.0.0.1:8000>: Failed to handle
request:
request = GET / HTTP/1.1 from ('127.0.0.1', 51984)
application = <function websocket_app at 0xb72a2e64>
127.0.0.1 - - [2012-01-13 14:50:40] "GET / HTTP/1.1" 000 0 0.000454
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gevent-0.13.6-py2.7-
linux-i686.egg/gevent/greenlet.py", line 390, in run
result = self._run(*self.args, **self.kwargs)
File "/usr/local/lib/python2.7/dist-packages/gevent-0.13.6-py2.7-
linux-i686.egg/gevent/pywsgi.py", line 571, in handle
handler.handle()
File "/usr/local/lib/python2.7/dist-packages/gevent-0.13.6-py2.7-
linux-i686.egg/gevent/pywsgi.py", line 180, in handle
result = self.handle_one_request()
File "/usr/local/lib/python2.7/dist-packages/gevent-0.13.6-py2.7-
linux-i686.egg/gevent/pywsgi.py", line 314, in handle_one_request
self.handle_one_response()
File "/usr/local/lib/python2.7/dist-packages/gevent_websocket-0.2.2-
py2.7.egg/geventwebsocket/handler.py", line 49, in handle_one_response
return super(WebSocketHandler, self).handle_one_response()
File "/usr/local/lib/python2.7/dist-packages/gevent-0.13.6-py2.7-
linux-i686.egg/gevent/pywsgi.py", line 454, in handle_one_response
self.start_response(_INTERNAL_ERROR_STATUS,
_INTERNAL_ERROR_HEADERS)
File "/usr/local/lib/python2.7/dist-packages/gevent_websocket-0.2.2-
py2.7.egg/geventwebsocket/handler.py", line 109, in start_response
if self.websocket_connection:
AttributeError: 'WebSocketHandler' object has no attribute
'websocket_connection'
<Greenlet at 0xb7310becL: <bound method WSGIServer.handle of
<WSGIServer at 0xb72a1facL fileno=3 address=
127.0.0.1:8000>>(<socket
at 0xb72a64ccL fileno=[Errno 9] Bad file d, ('127.0.0.1', 51984))>
failed with AttributeError
Does anyone know what I am doing wrong?
Thanks so much for the help!
Allard