Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bgK opened this issue Mar 21, 2025 · 4 comments · Fixed by #1618
Closed

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

bgK opened this issue Mar 21, 2025 · 4 comments · Fixed by #1618

Comments

@bgK
Copy link

bgK commented Mar 21, 2025

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.

@aaugustin
Copy link
Member

This is a valid improvement request (although I didn't really want to become an expert in HTTP proxies when I started this library...)

Out of curiosity, in what environment are you hitting this problem? Do you know what proxy is being used?

@bgK
Copy link
Author

bgK commented Mar 25, 2025

Out of curiosity, in what environment are you hitting this problem? Do you know what proxy is being used?

The proxy server is very much out of my reach, but looks like McAfee Web Gateway / Skyhigh Secure Web Gateway.

@aaugustin
Copy link
Member

OK - looks like a typical corporate environment - clearly in scope of what I wanted to support when I implemented support for HTTP proxies. I'll do something about it.

aaugustin added a commit that referenced this issue Apr 14, 2025
It is legal to answer an HTTP/1.1 request with an HTTP/1.0 response.

Fix #1609.
@aaugustin
Copy link
Member

Hello, would you be able to confirm that #1618 fixes your problem, please?

aaugustin added a commit that referenced this issue Apr 21, 2025
It is legal to answer an HTTP/1.1 request with an HTTP/1.0 response.

Fix #1609.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants