Skip to content

ValueError: unsupported protocol with HTTP/1.0 proxy server #1609

@bgK

Description

@bgK

When using websockets 15.0.1 to establish a connection through a HTTP/1.0 only proxy server, I get the following traceback:

venv/lib64/python3.11/site-packages/websockets/asyncio/client.py:765: in run_parser
    next(self.parser)
venv/lib64/python3.11/site-packages/websockets/http11.py:250: in parse
    raise ValueError(
E   ValueError: unsupported protocol; expected HTTP/1.1: HTTP/1.0 200 Connection Established

The above exception was the direct cause of the following exception:
tests/test_notification.py:31: in test_websocket
    async with websockets.connect(uri, origin = gateway_url, additional_headers = additional_headers, ssl = ssl_context, proxy = proxy) as websocket:
venv/lib64/python3.11/site-packages/websockets/asyncio/client.py:587: in __aenter__
    return await self
venv/lib64/python3.11/site-packages/websockets/asyncio/client.py:541: in __await_impl__
    self.connection = await self.create_connection()
venv/lib64/python3.11/site-packages/websockets/asyncio/client.py:440: in create_connection
    transport = await connect_http_proxy(
venv/lib64/python3.11/site-packages/websockets/asyncio/client.py:815: in connect_http_proxy
    await protocol.response
E   websockets.exceptions.InvalidProxyMessage: did not receive a valid HTTP response from proxy

Manually checking the behavior of the proxy server:

$ nc proxy-host.com 3128
CONNECT websocket-host.com:443 HTTP/1.1
Host: websocket-host.com

HTTP/1.0 200 Connection Established

It is my understanding reading the spec that responding with HTTP/1.0 to a HTTP/1.1 request is allowed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions