Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Unicode-objects must be encoded before hashing #38

Open
ChillingVan opened this issue Aug 6, 2016 · 3 comments
Open

Unicode-objects must be encoded before hashing #38

ChillingVan opened this issue Aug 6, 2016 · 3 comments

Comments

@ChillingVan
Copy link

ChillingVan commented Aug 6, 2016

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
Copy link
Author

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
Copy link
Author

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
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants