diff --git a/gql/transport/websockets_base.py b/gql/transport/websockets_base.py index 45c96d3e..5c7713e9 100644 --- a/gql/transport/websockets_base.py +++ b/gql/transport/websockets_base.py @@ -512,7 +512,11 @@ async def connect(self) -> None: await self._initialize() except ConnectionClosed as e: raise e - except (TransportProtocolError, asyncio.TimeoutError) as e: + except ( + TransportProtocolError, + TransportServerError, + asyncio.TimeoutError, + ) as e: await self._fail(e, clean_close=False) raise e diff --git a/tests/test_websocket_query.py b/tests/test_websocket_query.py index e8b7a022..d2270e7d 100644 --- a/tests/test_websocket_query.py +++ b/tests/test_websocket_query.py @@ -441,6 +441,9 @@ async def test_websocket_connect_failed_with_authentication_in_connection_init( await session.execute(query1) + await asyncio.sleep(1) + assert transport.websocket is None + @pytest.mark.parametrize("server", [server1_answers], indirect=True) def test_websocket_execute_sync(server):