zeekay / bottle-websocket

🍾 Easy websockets for bottle.
MIT License
132 stars 29 forks source link

python3.5 not work #9

Open dukelec opened 8 years ago

dukelec commented 8 years ago
duke@duke-uf /mnt/TT/p2p $ python3.5 ser.py 
Bottle v0.12.9 server starting up (using GeventWebSocketServer())...
Listening on http://127.0.0.1:8001/
Hit Ctrl-C to quit.

Traceback (most recent call last):
  File "/usr/lib64/python3.5/site-packages/gevent/greenlet.py", line 534, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/lib64/python3.5/site-packages/gevent/baseserver.py", line 25, in _handle_and_close_when_done
    return handle(*args_tuple)
  File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 1253, in handle
    handler.handle()
  File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 443, in handle
    result = self.handle_one_request()
  File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 658, in handle_one_request
    self.handle_one_response()
  File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 916, in handle_one_response
    self.log_request()
  File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 236, in log_request
    if '101' not in self.status:
TypeError: a bytes-like object is required, not 'str'
<Greenlet at 0x7fe9fed65af8: _handle_and_close_when_done(<bound method WSGIServer.handle of <WSGIServer at , <bound method StreamServer.do_close of <WSGIServer, (<gevent._socket3.socket [closed]  object, fd=-1, )> failed with TypeError

Traceback (most recent call last):
  File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 884, in handle_one_response
    self.run_application()
  File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 70, in run_application
    self.result = self.upgrade_websocket()
  File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 129, in upgrade_websocket
    return self.upgrade_connection()
  File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 219, in upgrade_connection
    hashlib.sha1(key + self.GUID).digest())),
TypeError: Unicode-objects must be encoded before hashing
{'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, sdch',
 'HTTP_ACCEPT_LANGUAGE': 'zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4',
 'HTTP_CACHE_CONTROL': 'no-cache',
 'HTTP_CONNECTION': 'Upgrade',
 'HTTP_HOST': '127.0.0.1:8001',
 'HTTP_ORIGIN': 'http://localhost:8001',
 'HTTP_PRAGMA': 'no-cache',
 'HTTP_SEC_WEBSOCKET_EXTENSIONS': 'permessage-deflate; client_max_window_bits',
 'HTTP_SEC_WEBSOCKET_KEY': 'GqFj9N4XhFEex2uEF7Xs/A==',
 'HTTP_SEC_WEBSOCKET_VERSION': '13',
 'HTTP_UPGRADE': 'websocket',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 '
                    '(KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36',
 'PATH_INFO': '/websocket',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '127.0.0.1',
 'REMOTE_PORT': '38446',
 'REQUEST_METHOD': 'GET',
 'SCRIPT_NAME': '',
 'SERVER_NAME': 'localhost',
 'SERVER_PORT': '8001',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SOFTWARE': 'gevent/1.1 Python/3.5',
 'wsgi.errors': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>,
 'wsgi.input': <gevent.pywsgi.Input object at 0x7fe9fdc51948>,
 'wsgi.multiprocess': False,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0),
 'wsgi.websocket': <geventwebsocket.websocket.WebSocket object at 0x7fe9fd7b1250>,
 'wsgi.websocket_version': '13'} failed with TypeError

Traceback (most recent call last):
  File "/usr/lib64/python3.5/site-packages/gevent/greenlet.py", line 534, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/lib64/python3.5/site-packages/gevent/baseserver.py", line 25, in _handle_and_close_when_done
    return handle(*args_tuple)
  File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 1253, in handle
    handler.handle()
  File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 443, in handle
    result = self.handle_one_request()
  File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 658, in handle_one_request
    self.handle_one_response()
  File "/usr/lib64/python3.5/site-packages/gevent/pywsgi.py", line 916, in handle_one_response
    self.log_request()
  File "/usr/lib64/python3.5/site-packages/geventwebsocket/handler.py", line 236, in log_request
    if '101' not in self.status:
TypeError: a bytes-like object is required, not 'str'
<Greenlet at 0x7fe9fdc55df0: _handle_and_close_when_done(<bound method WSGIServer.handle of <WSGIServer at , <bound method StreamServer.do_close of <WSGIServer, (<gevent._socket3.socket [closed]  object, fd=-1, )> failed with TypeError
colobas commented 7 years ago

have you had any luck in solving this?

benad commented 7 years ago

You may want to replace gevent-websocket with this fork: https://github.com/karellen/karellen-geventws .

colobas commented 7 years ago

@benad perfect! thanks a lot!

vascowhite commented 6 years ago

https://github.com/karellen/karellen-geventws now advises that you use https://github.com/jgelens/gevent-websocket