aiohttp ClientConnectionError SSL shutdown timed out when closing Microsoft Graph connection

Henri Coorevits 40 Reputation points
2025-05-30T17:21:12.8566667+00:00

I’m using Python 3.11.11 and aiohttp 3.11.18 to talk to Microsoft Graph (endpoints like /sendMail and /delta). Every request completes successfully (I get 200 or 202), but as soon as aiohttp tries to tear down the HTTPS connection I see:

ClientConnectionError: Connection lost: SSL shutdown timed out

This only started happening around May 30, 2025 and I never see the error when calling Google APIs or other services. It only appears when the aiohttp.ClientSession (or its TCPConnector) is closed or cleaned up after a Graph call.

What’s going on here? Has Microsoft Graph changed its TLS shutdown behavior recently? How can I either work around or properly handle this “close_notify” handshake timeout?

Environment

  • Python 3.11.11 (Windows/Linux)
  • aiohttp 3.11.18
  • msal 1.32.3
  • Observed only with Microsoft Graph endpoints

Any pointers or confirmation of a Graph-side TLS change would be greatly appreciated!

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Achilles Demey 130 Reputation points
    2025-06-01T20:47:19.9733333+00:00

    Hi everyone,

    This issue with aiohttp throwing SSL shutdown timeouts has been identified and tracked here: https://github.com/aio-libs/aiohttp/issues/11091

    It's not limited to one use case—it has also impacted interactions with Microsoft services, such as Azure SDK for Python: https://github.com/Azure/azure-sdk-for-python/issues/41363

    Recommended temporary workaround: Pin your aiohttp version to 3.12.3, which avoids the regression for now.

    You can do this in your requirements.txt or pyproject.toml until a more permanent fix is released.

    Hope this helps!

    3 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Ravi Puvvula 5 Reputation points
    2025-05-31T06:41:56.05+00:00

    I am having the same issue. Were you able you fix this error?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.