WebSocket-for-Python icon indicating copy to clipboard operation
WebSocket-for-Python copied to clipboard

HandshakeError: Header HTTP_UPGRADE is not defined

Open jcubic opened this issue 9 years ago • 2 comments

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.

jcubic avatar Jan 29 '16 18:01 jcubic

It was year ago, probably the error from the title.

jcubic avatar Jan 16 '17 22:01 jcubic

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

MRZA-MRZA avatar Jun 02 '18 17:06 MRZA-MRZA