azure-sdk-for-python: All async Azure storage account connections hang with SSL shutdown timeout errors in latest version of aiohttp
- Package Name: azure-data-tables/azure-storage-file-share
- Package Version: 12.7.0/12.21.0
- Operating System: macOS Sequoia v15.5
- Python Version: 3.11.12
Describe the bug Since the release of version 3.12.4 of aiohttp yesterday, any asynchronous connections to Azure tables or file shares within a storage account seem to hang for 30 seconds after completing, and following this there is an error message logged - “Error while closing connector: ClientConnectionError(‘Connection lost: SSL shutdown timed out’)”
We’ve tested the following scenarios:
- Tested this both on a local Mac and on a Linux GitHub Actions runner, with the same result on both.
- Tested connecting to a CosmosDB account through the azure-cosmos package which also uses aiohttp, and this works fine, which leads me to believe the issue is storage-account related, rather than the wider Azure SDK or aiohttp itself.
- Tested connecting to multiple different storage accounts - same result for all.
- Tested connecting to tables and file shares - I suspect blob storage and queues have the same problem, but haven’t explicitly tested.
The issue only seems to occur if you actually perform an action on a table/file share - if you just connect but don’t do anything, that’s fine.
To Reproduce Steps to reproduce the behavior:
- See the below Python script that replicates the issue:
import asyncio
import logging
from azure.data.tables.aio import TableServiceClient
logger = logging.getLogger(__name__)
async def create_table_with_async_table_service_client() -> None:
logger.info("Creating table asynchronously...")
async with TableServiceClient.from_connection_string("<connection_string>") as table_service_client:
await table_service_client.create_table_if_not_exists("TestTable")
logger.info("TestTable created successfully or already exists")
logger.info("AsyncTableServiceClient exited successfully")
async def do_nothing_in_async_table_service_client() -> None:
logger.info("Doing nothing in AsyncTableServiceClient...")
async with AsyncTableServiceClient.from_connection_string("<connection_string>"):
logger.info("AsyncTableServiceClient is ready for use - doing nothing")
logger.info("AsyncTableServiceClient exited successfully")
async def main() -> None:
logging.basicConfig(level=logging.INFO)
await create_table_with_async_table_service_client()
await do_nothing_in_async_table_service_client()
if __name__ == "__main__":
asyncio.run(main())
Expected behavior
In above script, the create_table_with_async_table_service_client function will hang upon exiting the TableServiceClient async context manager, and an error will eventually be logged to the root logger, saying that the SSL shutdown timed out. The do_nothing_in_async_table_service_client function will run normally without this issue.
EDIT: misunderstood this section earlier - expected behaviour is obviously that the table service client closes without an SSL shutdown timeout error and without the 30s delay
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Pinning aiohttp to an earlier version works as a temporary workaround to prevent the mass slowdown resulting from all asynchronous storage account connections hanging.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 9
- Comments: 19 (6 by maintainers)
I think the aiohttp team are probably right that it’s not a bug on their end, as looking at the PR that went into the v3.12.4 release, it looks like the new behaviour is very much intentional, and is actually the result of a bug fix. Furthermore, if it were a bug in the aiohttp package then I’d expect it to affect all services, not just Azure storage account operations.
To be honest, I suspect that this issue has been present in the Azure SDK for a while, but has only just been exposed by the latest aiohttp bug fix.
I would dig into it further myself, but I’ve already sunk a few hours into it today and have other projects that are more pressing
3.12.4 is what broke it. The fix in 3.12.6 reduced the timeout so performance should be better but the error will still be raised. I think Azure needs a fix either in the SDK or the TLS stack to make the error go away. I’m going to use 3.12.3 until there is a fix from the azure side
Hello, quick update on this topic:
Short version: Pin your aiohttp version to 3.12.3 for now.
Long version: We are able to reproduce the issue without using a SDK, just direct
aiohttp. We tested many combinations of OS, Python versions, corporate “complex network” and simple personal machine, and we can consistently reproduce it using our few lines ofaiohttpcode. At this point, we exclude a SDK bug, but it can be anywhere between the Azure server and aiohttp, including Python itself (we’re trying to not be biased and keep all options equally possible). I expect this investigation to take some time, as it seems we need to go deeper into low level layers of code. The best solution we can suggest right now is sticking toaiohttp3.12.3.@JamieForsythe can you please /unresolve so the azure team knows they need to look at this.
Hi @JamieForsythe. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.
Hi @JamieForsythe, I’m an AI Support assistant here to help with your issue. While the Azure SDK team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
The Azure SDK team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!
Update. This week-end
aiohttpteam released 3.12.11, addressing this problem again, see this from their ChangeLog:We confirmed that we’re not able to reproduce any problems anymore in any Python version with this new version.
Given the Azure SDK all along was just calling
.close()from aiohttp, and now it’s closing without any errors thrown, we consider this issue adressed. We have an ongoing discussion with the Storage team around their implementation of TLS 1.3, but any conclusions there would still not require any SDK fixes and be transparent for SDK users (it may change the pathaiohttpwould follow, still deeper than SDK code). So I’m marking this issue as addressed. Please comment if anything else is needed.I tried upgrading to 3.12.12 and still hit the “ClientConnectionError(‘Connection lost: SSL shutdown timed out’)” issue. Downgrading to 3.12.3 resolved the error.