MarkNenadov / websocket_proxpy

A WebSocket proxy server using Python 3.
GNU Lesser General Public License v2.1
20 stars 5 forks source link

ValueError: Line without CRLF when connecting to a websocket vnc server #1

Open Meow-ops opened 6 years ago

Meow-ops commented 6 years ago

I tried to use this code to connect a client to a qemu vnc websocket server. Without the proxy, it is working fine. With the proxy, the client connects to the proxy server but the server cannot connect to the qemu vnc server. I have the following error :

2018/01/10-16:28:05 DEBUG Connection established with CLIENT

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/websockets/client.py", line 80, in read_http_response
    status_code, headers = yield from read_response(self.reader)
  File "/usr/local/lib/python3.4/dist-packages/websockets/http.py", line 119, in read_response
    status_line = yield from read_line(stream) 
  File "/usr/local/lib/python3.4/dist-packages/websockets/http.py", line 195, in read_line
    raise ValueError("Line without CRLF")
ValueError: Line without CRLF

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/websockets/server.py", line 135, in handler
    yield from self.ws_handler(self, path)
  File "ws_proxy.py", line 123, in proxy_dispatcher
    proxied_web_socket = yield from self.connect_to_proxy_server(proxied_url_value, proxy_web_socket)
  File "ws_proxy.py", line 233, in connect_to_proxy_server
    proxied_web_socket = yield from websockets.connect(proxied_url_value)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/local/lib/python3.4/dist-packages/websockets/client.py", line 400, in __await__
    extra_headers=protocol.extra_headers,
  File "/usr/local/lib/python3.4/dist-packages/websockets/client.py", line 259, in handshake
    status_code, response_headers = yield from self.read_http_response()
  File "/usr/local/lib/python3.4/dist-packages/websockets/client.py", line 82, in read_http_response
    raise InvalidMessage("Malformed HTTP message") from exc

To reproduce, just start a qemu qemu-system-x86_64 -vnc :0,websocket=5700, launch the proxy with the following options :

host 0.0.0.0
port 5800
proxified_url ws://localhost:5700/

Any idea on how to fix this?

MarkNenadov commented 6 years ago

Thanks for reporting this. I can reproduce that problem. However, it seems to be some sort of more general problem not exclusively limited to websocket_proxypy.

I can't connect to that qemu websocket instance even with a minimalistic javascript client implementation (with no proxy) either.

MarkNenadov commented 6 years ago

Feel free to provide any additional details and perhaps we can investigate more.