Repository navigation
Broken master build: SSL_WRONG_VERSION_NUMBER #276
Copy link
Copy link
Closed
Description
We have a CI build error that I saw in the latest master build as well as some other branches, eg #275.
- Not able to reproduce on my local macOS machine. CI uses Linux -> Can someone on Linux reproduce by running the test suite?
- It happens in
test_connection_timeout_tcp, which does something hacky: try to connect via HTTPS to generate aConnectTimeout. In CI we get aConnectErrorinstead. Probably related to the underlyingopensslversion?
https://github.com/encode/httpcore/runs/1785395873?check_suite_focus=true#step:7:79
__________________ test_connection_timeout_tcp[asyncio-auto] ___________________
backend = 'auto'
server = <tests.utils.HypercornServer object at 0x7f7f41716810>
@pytest.mark.skipif(
sys.version_info[:2] < (3, 7),
reason="Hypercorn doesn't support python < 3.7 (this test is local-only)",
)
@pytest.mark.anyio
async def test_connection_timeout_tcp(backend: str, server: Server) -> None:
# we try to access http server using https. It caused some SSL timeouts
# in TLSStream.wrap inside inside AnyIOBackend.open_tcp_stream
method = b"GET"
url = (b"https", *server.netloc, b"/")
headers = [server.host_header]
ext = {"timeout": {"connect": 0.1}}
async with httpcore.AsyncConnectionPool(backend=backend) as http:
with pytest.raises(httpcore.ConnectTimeout):
> await http.arequest(method, url, headers, ext=ext)
tests/async_tests/test_interfaces.py:487:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
httpcore/_async/connection_pool.py:259: in arequest
socket = await self._open_socket(origin, timeout=timeout)
httpcore/_async/connection_pool.py:214: in _open_socket
local_address=self._local_address,
httpcore/_backends/auto.py:45: in open_tcp_stream
hostname, port, ssl_context, timeout, local_address=local_address
httpcore/_backends/asyncio.py:268: in open_tcp_stream
connect_timeout,
/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/contextlib.py:130: in __exit__
self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
map = {<class 'concurrent.futures._base.TimeoutError'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: Dict[Type[Exception], Type[Exception]]) -> Iterator[None]:
try:
yield
except Exception as exc: # noqa: PIE786
for from_exc, to_exc in map.items():
if isinstance(exc, from_exc):
> raise to_exc(exc) from None
E httpcore.ConnectError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1091)
httpcore/_exceptions.py:12: ConnectError
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
euri10 commentedon Feb 23, 2021
yes it does fail
I get this
WRONG_VERSION_NUMBERindeedJayH5 commentedon Feb 23, 2021
I had a (failed) go at fixing this in #270. There definitely seem to be some differences in connection establishment in these edge cases between macOS and Linux.
IMO, the Linux error makes more sense and the tests shouldn't really be mis-using an SSL error to test this. However, I wasn't able to find a way to test connection timeouts on Linux easily.
florimondmanca commentedon Mar 23, 2021
Solved by #282.