heroku-python / flask-sockets

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

Unicode-objects must be encoded before hashing #38

Open ChillingVan opened 8 years ago

ChillingVan commented 8 years ago

Hello. in geventwebsocket/handler.py headers = [ ("Upgrade", "websocket"), ("Connection", "Upgrade"), ("Sec-WebSocket-Accept", base64.b64encode( hashlib.sha1(key + self.GUID).digest())), ]

Is it OK that key and self.GUID do not use encode('utf-8') method? I met an exception: File "~/geventwebsocket/handler.py", line 219, in upgrade_connection hashlib.sha1(key + self.GUID).digest())), TypeError: Unicode-objects must be encoded before hashing

my dev environment: Python3.5 gevent 1.1.2 gevent-websocket 0.95

I tried to encode the key and self.GUID, but I met other errors then : UnicodeError("The value must be a native string", header, value) this occurs at pywsgi.py at function start_response() because the value of sec websocket key is a byte object.

Of course I change it to a str, then I met other error.....

Thanks for checking this issue.

ChillingVan commented 8 years ago

Just now I read the Readme.md and learned that I should use gunicorn to deploy. Let me try again. I am sorry that I missed the important information in Readme...

ChillingVan commented 8 years ago

I tried to use gunicorn but got same error... I search on Google and only get answer that gevent does not support python3 well. Is that true?

shagunsodhani commented 7 years ago

That does seems to be the issue. I could run it using Python2 but not Python3