WebSocket-for-Python
WebSocket-for-Python copied to clipboard
HandshakeError: Header HTTP_UPGRADE is not defined
I've run wsgiref example code with this JS:
var connection = new WebSocket('ws://localhost:9000/');
connection.onmessage = function(e) {
console.log('Server: ' + e.data);
};
connection.onopen = function() {
connection.send(JSON.stringify({message: 'hello'}));
};
I I've got this error but the socket is working, I get {message: 'hello'} in response. I'm using Python 2.7.10.
It was year ago, probably the error from the title.
I faced the same error when using wsgiref example with apache and nginx:
Traceback (most recent call last):
File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/pi/.local/lib/python3.5/site-packages/ws4py/server/wsgiutils.py", line 101, in __call__
raise HandshakeError('Header %s is not defined' % key)
ws4py.exc.HandshakeError: Header HTTP_UPGRADE is not defined