Skip to content

Test failures with Python 3.13.6 #1648

Closed

Description

@mweinelt

With Python 3.13.6 (up from 3.13.5) we started seeing test failures around TLS connections in the test suite on 15.0.1 (and also on 91abba4).

websockets> unittest flags: ''
websockets> .......................................sssssssssssssss.......ssssssss...................................................................................................................................................................s....s.s........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ss...............................................................................................................................................................................................................................................................................................................................................................E...........................sssssssssssssssE..EEssssssss.E.E.................................................s..............................................................s.s...............................s...................................................................................................................E.E............E..E.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
websockets> ======================================================================
websockets> ERROR: test_ssl_context_argument (tests.sync.test_client.BackwardsCompatibilityTests.test_ssl_context_argument)
websockets> Client supports the deprecated ssl_context argument.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_client.py", line 712, in test_ssl_context_argument
websockets>     with connect(get_uri(server), ssl_context=CLIENT_CONTEXT):
websockets>          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ======================================================================
websockets> ERROR: test_connection (tests.sync.test_client.SecureClientTests.test_connection)
websockets> Client connects to server securely.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_client.py", line 261, in test_connection
websockets>     with connect(get_uri(server), ssl=CLIENT_CONTEXT) as client:
websockets>          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ======================================================================
websockets> ERROR: test_set_server_hostname_explicitly (tests.sync.test_client.SecureClientTests.test_set_server_hostname_explicitly)
websockets> Client sets server_hostname to the value provided in argument.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_client.py", line 278, in test_set_server_hostname_explicitly
websockets>     with unix_connect(
websockets>          ~~~~~~~~~~~~^
websockets>         path, ssl=CLIENT_CONTEXT, server_hostname="overridden"
websockets>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>     ) as client:
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 419, in unix_connect
websockets>     return connect(uri=uri, unix=True, path=path, **kwargs)
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ======================================================================
websockets> ERROR: test_set_server_hostname_implicitly (tests.sync.test_client.SecureClientTests.test_set_server_hostname_implicitly)
websockets> Client sets server_hostname to the host in the WebSocket URI.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_client.py", line 269, in test_set_server_hostname_implicitly
websockets>     with unix_connect(
websockets>          ~~~~~~~~~~~~^
websockets>         path, ssl=CLIENT_CONTEXT, uri="wss://overridden/"
websockets>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>     ) as client:
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 419, in unix_connect
websockets>     return connect(uri=uri, unix=True, path=path, **kwargs)
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ======================================================================
websockets> ERROR: test_secure_connection (tests.sync.test_client.UnixClientTests.test_secure_connection)
websockets> Client connects to server securely over a Unix socket.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_client.py", line 620, in test_secure_connection
websockets>     with unix_connect(path, ssl=CLIENT_CONTEXT) as client:
websockets>          ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 419, in unix_connect
websockets>     return connect(uri=uri, unix=True, path=path, **kwargs)
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ======================================================================
websockets> ERROR: test_set_server_hostname (tests.sync.test_client.UnixClientTests.test_set_server_hostname)
websockets> Client sets server_hostname to the host in the WebSocket URI.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_client.py", line 629, in test_set_server_hostname
websockets>     with unix_connect(
websockets>          ~~~~~~~~~~~~^
websockets>         path, ssl=CLIENT_CONTEXT, uri="wss://overridden/"
websockets>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>     ) as client:
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 419, in unix_connect
websockets>     return connect(uri=uri, unix=True, path=path, **kwargs)
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ======================================================================
websockets> ERROR: test_secure_redirect (tests.sync.test_router.RouterTests.test_secure_redirect)
websockets> Router redirects connections to a wss:// URI when TLS is enabled.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_router.py", line 83, in test_secure_redirect
websockets>     with connect(get_uri(server) + "/r", ssl=CLIENT_CONTEXT):
websockets>          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ======================================================================
websockets> ERROR: test_ssl_context_argument (tests.sync.test_server.BackwardsCompatibilityTests.test_ssl_context_argument)
websockets> Server supports the deprecated ssl_context argument.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_server.py", line 574, in test_ssl_context_argument
websockets>     with connect(get_uri(server), ssl=CLIENT_CONTEXT):
websockets>          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ======================================================================
websockets> ERROR: test_connection (tests.sync.test_server.SecureServerTests.test_connection)
websockets> Server receives secure connection from client.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_server.py", line 346, in test_connection
websockets>     with connect(get_uri(server), ssl=CLIENT_CONTEXT) as client:
websockets>          ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ======================================================================
websockets> ERROR: test_connection (tests.sync.test_server.SecureUnixServerTests.test_connection)
websockets> Server receives secure connection from client over a Unix socket.
websockets> ----------------------------------------------------------------------
websockets> Traceback (most recent call last):
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
websockets>     self.send_data()
websockets>     ~~~~~~~~~~~~~~^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
websockets>     self.socket.sendall(data)
websockets>     ~~~~~~~~~~~~~~~~~~~^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
websockets>     v = self.send(byte_view[count:])
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/ssl.py", line 1232, in send
websockets>     return self._sslobj.write(data)
websockets>            ~~~~~~~~~~~~~~~~~~^^^^^^
websockets> ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
websockets> 
websockets> The above exception was the direct cause of the following exception:
websockets> 
websockets> Traceback (most recent call last):
websockets>   File "/build/source/tests/sync/test_server.py", line 380, in test_connection
websockets>     with unix_connect(path, ssl=CLIENT_CONTEXT) as client:
websockets>          ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 419, in unix_connect
websockets>     return connect(uri=uri, unix=True, path=path, **kwargs)
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
websockets>     connection.handshake(
websockets>     ~~~~~~~~~~~~~~~~~~~~^
websockets>         additional_headers,
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>         user_agent_header,
websockets>         ^^^^^^^^^^^^^^^^^^
websockets>         deadline.timeout(),
websockets>         ^^^^^^^^^^^^^^^^^^^
websockets>     )
websockets>     ^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
websockets>     with self.send_context(expected_state=CONNECTING):
websockets>          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
websockets>   File "/nix/store/lcpjgrp7x4f9rv5zhdcbbysg11ia33f3-python3-3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
websockets>     next(self.gen)
websockets>     ~~~~^^^^^^^^^^
websockets>   File "/nix/store/551prrpxwx2fvcglb9pzkr0zgl8lg8yb-python3.13-websockets-15.0.1/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
websockets>     raise self.protocol.close_exc from original_exc
websockets> websockets.exceptions.ConnectionClosedError: no close frame received or sent
websockets> 
websockets> ----------------------------------------------------------------------
websockets> Ran 1947 tests in 177.421s

Activity

  1. aaugustin commented on Aug 9, 2025

    @aaugustin
    Member

    I could reproduce on macOS on my first attempt, while you're on Linux, so this looks like a reproducible platform-independent problem. (Phew.)

    Also, the tests don't just fail; they also hang for 10 seconds — which is the default close timeout for connections — before failing.

    python/cpython#134724 is a candidate in the right area: it's a fix for a bug involving custom certificates and threads and it adds a lock; the failing tests involve custom certificates and threads and they're blocking now. However, it isn't completely obvious that it's the cause of the problem.

    The next step would be to write a minimal reproduction without websockets to prove that it's a Python problem.

  2. aaugustin commented on Aug 9, 2025

    @aaugustin
    Member

    Reducing the problem to a single failing test (every failure follows the same pattern) and adding logs:

    $ WEBSOCKETS_DEBUG=1 python -m unittest -v tests.sync.test_client.SecureClientTests.test_connection
    test_connection (tests.sync.test_client.SecureClientTests.test_connection)
    Client connects to server securely. ... 2025-08-09 08:30:12,611 DEBUG websockets.client = connection is CONNECTING
    2025-08-09 08:30:12,611 DEBUG websockets.server = connection is CONNECTING
    2025-08-09 08:30:12,611 DEBUG websockets.client > GET / HTTP/1.1
    2025-08-09 08:30:12,611 DEBUG websockets.client > Host: 127.0.0.1:51970
    2025-08-09 08:30:12,611 DEBUG websockets.client > Upgrade: websocket
    2025-08-09 08:30:12,611 DEBUG websockets.client > Connection: Upgrade
    2025-08-09 08:30:12,611 DEBUG websockets.client > Sec-WebSocket-Key: jjSVQ7XPjx2GIXKfQ49QDQ==
    2025-08-09 08:30:12,611 DEBUG websockets.client > Sec-WebSocket-Version: 13
    2025-08-09 08:30:12,611 DEBUG websockets.client > Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
    2025-08-09 08:30:12,611 DEBUG websockets.client > User-Agent: Python/3.13 websockets/15.0.1
    2025-08-09 08:30:22,614 DEBUG websockets.server > EOF
    2025-08-09 08:30:22,615 DEBUG websockets.server < EOF
    2025-08-09 08:30:22,615 DEBUG websockets.server = connection is CLOSED
    2025-08-09 08:30:22,615 DEBUG websockets.server ! error while receiving data
    Traceback (most recent call last):
      File "/Users/myk/dev/websockets/.direnv/python-3.13/lib/python3.13/site-packages/websockets/sync/connection.py", line 814, in recv_events
        data = self.socket.recv(self.recv_bufsize)
      File "/Users/myk/.pyenv/versions/3.13.6/lib/python3.13/ssl.py", line 1285, in recv
        return self.read(buflen)
               ~~~~~~~~~^^^^^^^^
      File "/Users/myk/.pyenv/versions/3.13.6/lib/python3.13/ssl.py", line 1140, in read
        return self._sslobj.read(len)
               ~~~~~~~~~~~~~~~~~^^^^^
    OSError: [Errno 9] Bad file descriptor
    2025-08-09 08:30:22,615 DEBUG websockets.client ! error while sending data
    Traceback (most recent call last):
      File "/Users/myk/dev/websockets/.direnv/python-3.13/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
        self.send_data()
        ~~~~~~~~~~~~~~^^
      File "/Users/myk/dev/websockets/.direnv/python-3.13/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
        self.socket.sendall(data)
        ~~~~~~~~~~~~~~~~~~~^^^^^^
      File "/Users/myk/.pyenv/versions/3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
        v = self.send(byte_view[count:])
      File "/Users/myk/.pyenv/versions/3.13.6/lib/python3.13/ssl.py", line 1232, in send
        return self._sslobj.write(data)
               ~~~~~~~~~~~~~~~~~~^^^^^^
    ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
    2025-08-09 08:30:22,616 DEBUG websockets.client > EOF
    2025-08-09 08:30:22,616 DEBUG websockets.client < EOF
    2025-08-09 08:30:22,616 DEBUG websockets.client = connection is CLOSED
    ERROR
    
    ======================================================================
    ERROR: test_connection (tests.sync.test_client.SecureClientTests.test_connection)
    Client connects to server securely.
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/myk/dev/websockets/.direnv/python-3.13/lib/python3.13/site-packages/websockets/sync/connection.py", line 963, in send_context
        self.send_data()
        ~~~~~~~~~~~~~~^^
      File "/Users/myk/dev/websockets/.direnv/python-3.13/lib/python3.13/site-packages/websockets/sync/connection.py", line 1029, in send_data
        self.socket.sendall(data)
        ~~~~~~~~~~~~~~~~~~~^^^^^^
      File "/Users/myk/.pyenv/versions/3.13.6/lib/python3.13/ssl.py", line 1263, in sendall
        v = self.send(byte_view[count:])
      File "/Users/myk/.pyenv/versions/3.13.6/lib/python3.13/ssl.py", line 1232, in send
        return self._sslobj.write(data)
               ~~~~~~~~~~~~~~~~~~^^^^^^
    ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2502)
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/Users/myk/dev/websockets/tests/sync/test_client.py", line 263, in test_connection
        with connect(get_uri(server), ssl=CLIENT_CONTEXT) as client:
             ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/myk/dev/websockets/.direnv/python-3.13/lib/python3.13/site-packages/websockets/sync/client.py", line 378, in connect
        connection.handshake(
        ~~~~~~~~~~~~~~~~~~~~^
            additional_headers,
            ^^^^^^^^^^^^^^^^^^^
            user_agent_header,
            ^^^^^^^^^^^^^^^^^^
            deadline.timeout(),
            ^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/Users/myk/dev/websockets/.direnv/python-3.13/lib/python3.13/site-packages/websockets/sync/client.py", line 85, in handshake
        with self.send_context(expected_state=CONNECTING):
             ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/myk/.pyenv/versions/3.13.6/lib/python3.13/contextlib.py", line 148, in __exit__
        next(self.gen)
        ~~~~^^^^^^^^^^
      File "/Users/myk/dev/websockets/.direnv/python-3.13/lib/python3.13/site-packages/websockets/sync/connection.py", line 1012, in send_context
        raise self.protocol.close_exc from original_exc
    websockets.exceptions.ConnectionClosedError: no close frame received or sent
    
    ----------------------------------------------------------------------
    Ran 1 test in 10.013s
    
    FAILED (errors=1)
    

    Here we can see that the client is sending data over the TLS-encrypted connection but the server never gets it.

    After 10 seconds, the opening handshake timeout triggers on the server side. (Not the close timeout like I thought at first.)

    The socket is then closed on the server side, leading to the error under websockets.server ! error while receiving data.

    From the client perspective, it hasn't finished sending the data yet, probably because it's waiting for a TLS acknowledgement, as visible in the error under websockets.client ! error while sending data.

  3. aaugustin commented on Aug 9, 2025

    @aaugustin
    Member

    Here's a minimal reproduction:

    import os
    import socket
    import ssl
    import threading
    
    
    TLS_HANDSHAKE_TIMEOUT = 1
    
    print("If Python locks hard:")
    print("kill -TERM", os.getpid())
    print()
    
    # Create TLS contexts with a self-signed certificate. Download it here:
    # https://github.com/python-websockets/websockets/blob/main/tests/test_localhost.pem
    
    server_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
    server_context.load_cert_chain(b"test_localhost.pem")
    # Work around https://github.com/openssl/openssl/issues/7967
    server_context.num_tickets = 0
    
    client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
    client_context.load_verify_locations(b"test_localhost.pem")
    
    
    # Start a socket server. Nothing fancy here. In a realistic server, we would
    # have `serve_forever` with a `while True:` loop. For a minimal reproduction,
    # `serve_one` is enough, as the bug occurs on the first request.
    
    server_sock = socket.create_server(("localhost", 0))
    server_port = server_sock.getsockname()[1]
    
    server_sock = server_context.wrap_socket(
        server_sock,
        server_side=True,
        # Delay TLS handshake until after we set a timeout on the socket.
        do_handshake_on_connect=False,
    )
    
    def conn_handler(sock, addr) -> None:
        print("server accepted connection from", addr)
        sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True)
    
        sock.settimeout(TLS_HANDSHAKE_TIMEOUT)
        assert isinstance(sock, ssl.SSLSocket)
        sock.do_handshake()
        sock.settimeout(None)
    
        handshake = sock.recv(4096)
        print("server rcvd:")
        print(handshake.decode())
        print()
    
    def serve_one():
        sock, addr = server_sock.accept()
        handler_thread = threading.Thread(target=conn_handler, args=(sock, addr))
        handler_thread.start()
    
    print("server listening on port", server_port)
    server_thread = threading.Thread(target=serve_one)
    server_thread.start()
    
    
    # Connect a client to the server. Again, nothing fancy.
    
    client_sock = socket.create_connection(("localhost", server_port))
    client_sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, True)
    
    client_sock.settimeout(TLS_HANDSHAKE_TIMEOUT)
    client_sock = client_context.wrap_socket(
        client_sock,
        server_hostname="localhost",
    )
    client_sock.settimeout(None)
    
    ### The bug happens only when we're reading from the client socket too! ###
    
    def recv_one_event():
        msg = client_sock.recv(4096)
        print("client rcvd:")
        print(msg.decode())
        print()
    
    client_background_thread = threading.Thread(target=recv_one_event)
    client_background_thread.start()
    
    ### If you remove client_background_thread.start(), it doesn't happen. ###
    
    handshake = (
        b"GET / HTTP/1.1\r\n"
        b"Host: 127.0.0.1:51970\r\n"
        b"Upgrade: websocket\r\n"
        b"Connection: Upgrade\r\n"
        b"Sec-WebSocket-Key: jjSVQ7XPjx2GIXKfQ49QDQ==\r\n"
        b"Sec-WebSocket-Version: 13\r\n"
        b"Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\r\n"
        b"User-Agent: Python/3.13 websockets/15.0.1\r\n"
        b"\r\n"
    )
    
    print("client send:")
    print(handshake.decode())
    print()
    client_sock.sendall(handshake)
  4. aaugustin commented on Aug 9, 2025

    @aaugustin
    Member

    Upstream issue filed against CPython here: python/cpython#137583

  5. ZeroIntensity commented on Aug 14, 2025

    @ZeroIntensity

    Upstream issue has been fixed in 3.13.7, which was just released.

  6. locked as spam and limited conversation to collaborators on Sep 28, 2025
  7. aaugustin commented on Sep 28, 2025

    @aaugustin
    Member

    For some reason this issue attracts spam. Locking in the hope of preventing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions