heroku-python / flask-sockets

[DEPRECATED] Alternative: https://github.com/miguelgrinberg/flask-sock
MIT License
1.74k stars 167 forks source link

Getting TypeError in the log on each request #39

Open apirogov opened 8 years ago

apirogov commented 8 years ago

Even when just trying the first example ("simple usage"), I get the following exception on each request:

Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/gevent/greenlet.py", line 534, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/lib/python3.5/site-packages/gevent/baseserver.py", line 25, in _handle_and_close_when_done
    return handle(*args_tuple)
  File "/usr/lib/python3.5/site-packages/gevent/pywsgi.py", line 1253, in handle
    handler.handle()
  File "/usr/lib/python3.5/site-packages/gevent/pywsgi.py", line 443, in handle
    result = self.handle_one_request()
  File "/usr/lib/python3.5/site-packages/gevent/pywsgi.py", line 658, in handle_one_request
    self.handle_one_response()
  File "/usr/lib/python3.5/site-packages/gevent/pywsgi.py", line 916, in handle_one_response
    self.log_request()
  File "/home/admin/.local/lib/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 0x7fda8555e048: _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

the strange thing is, the http requests work fine. I did not try the websocket route yet, as I first wanted to know if I'm doing something wrong or is this a bug?

ChillingVan commented 8 years ago

I also have same error. Is this because of we using python3?

benma commented 7 years ago

I also have this error, I am also using python3.

o3bvv commented 7 years ago

I also confirm this with Python 3. Runs good with Python 2. I'll take a look.

Traceback (most recent call last):
  File "/home/alex/.virtualenvs/services/lib/python3.4/site-packages/gevent/greenlet.py", line 534, in run
    result = self._run(*self.args, **self.kwargs)
  File "/home/alex/.virtualenvs/services/lib/python3.4/site-packages/gevent/baseserver.py", line 25, in _handle_and_close_when_done
    return handle(*args_tuple)
  File "/home/alex/.virtualenvs/services/lib/python3.4/site-packages/gevent/pywsgi.py", line 1253, in handle
    handler.handle()
  File "/home/alex/.virtualenvs/services/lib/python3.4/site-packages/gevent/pywsgi.py", line 443, in handle
    result = self.handle_one_request()
  File "/home/alex/.virtualenvs/services/lib/python3.4/site-packages/gevent/pywsgi.py", line 658, in handle_one_request
    self.handle_one_response()
  File "/home/alex/.virtualenvs/services/lib/python3.4/site-packages/gevent/pywsgi.py", line 916, in handle_one_response
    self.log_request()
  File "/home/alex/.virtualenvs/services/lib/python3.4/site-packages/geventwebsocket/handler.py", line 236, in log_request
    if '101' not in self.status:
TypeError: 'str' does not support the buffer interface
<Greenlet at 0x7efcaa0fa2a8: _handle_and_close_when_done(<bound method WSGIServer.handle of <WSGIServer at , <bound method WSGIServer.do_close of <WSGIServer a, (<gevent._socket3.socket [closed]  object, fd=-1, )> failed with TypeError
Xoerk commented 7 years ago

Any update? I'm getting it on python3 also.

arruda commented 7 years ago

Maybe this would be a solution: https://www.mkyong.com/python/python-3-typeerror-str-does-not-support-the-buffer-interface/

cemozerr commented 6 years ago

I too have the same issue with TypeError on python 3.

Alex-CodeLab commented 5 years ago

the example seems to be incorrect, should be

        something = {'data':'test'}
        ws.send(message=json.dumps(something))
BenePronomen commented 3 years ago

Still having this issue. It's 2020 and it breaks in python 3 -_-