Pithikos / python-websocket-server

A simple fully working websocket-server in Python with no external dependencies
MIT License
1.14k stars 381 forks source link

UnicodeDecodeError #64

Open 2t6h opened 6 years ago

2t6h commented 6 years ago

message = self.request.recv(1024).decode().strip() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa7 in position 4: invalid start byte

Laura055 commented 5 years ago

Yea I have the same problem

adeora commented 5 years ago

+1, also running into this

Jawmo commented 5 years ago

This appears due to trying to utilize an SSL on the server. I received the same message. Have you guys found a way around this? Are you also utilizing nginx in your projects?

When attempting a proxy_pass, I then receive a new error:

Traceback (most recent call last):
  File "/usr/lib/python3.6/socketserver.py", line 721, in __init__
    self.handle()
  File "/home/damian/hopemud/websocket_server/websocket_server.py", line 199, in handle
    self.handshake()
  File "/home/damian/hopemud/websocket_server/websocket_server.py", line 337, in handshake
    assert headers['upgrade'].lower() == 'websocket'
KeyError: 'upgrade'
atrebbi commented 4 years ago

I had the same error I have proxied the websocket through apache, that manages ssl , with the following in VirtualHost (the websocket server runs on port 13100)

<VirtualHost :443> ... RewriteEngine on RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC] RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC] RewriteRule . ws://yourserver.com:13100%{REQUEST_URI} [P] ...

and my client simply connects to
wss://yourserver.com

Alveona commented 4 years ago

I accidentally tried to connect through 'wss' to my local server, which hadn't any certificates and that was causing this error. Changing to 'ws' protocol resolved this