AmqpOverWebsocket leaks aiohttp.ClientSession instances when network disconnects during send_messages()
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- azure, python
- 领域
- backend, networking
调研方向
Start in azure/servicebus/_pyamqp/aio_transport_async.py at connect() (reported line 451), then reproduce with the supplied async MRE while disconnecting the network before send_messages(). Trace the failed connection and retry path, and verify that every session created there is closed with no "Unclosed client session" warnings.
由索引模型根据 Issue 内容生成。
描述
Package
- azure-servicebus: 7.14.3
- azure-core: 1.41.0
- azure-identity: 1.25.3
- aiohttp: 3.14.3
- Python: 3.13.7
- OS: Windows 11 Enterprise
Describe the bug
When using the async Service Bus client with TransportType.AmqpOverWebsocket, disconnecting the network immediately before sender.send_messages() causes multiple Unclosed client session warnings.
The warnings point to azure/servicebus/_pyamqp/aio_transport_async.py, specifically line 451 in connect(), where the aiohttp.ClientSession is created.
The application uses the documented async context-manager pattern, so the Service Bus client, sender, and credential are all explicitly managed with async with.
Minimal reproduction
Execute the MRE below and disconnect the network when instructed, before the message is sent.
import asyncio
from azure.servicebus import ServiceBusMessage, TransportType
from azure.servicebus.aio import ServiceBusClient
from azure.identity.aio import DefaultAzureCredential
SERVICE_BUS_NAMESPACE = "<your_service_bus_namespace_here>"
SERVICE_BUS_QUEUE_NAME = "<your_service_bus_queue_name_here>"
async def test():
async with DefaultAzureCredential() as cred:
async with ServiceBusClient(
SERVICE_BUS_NAMESPACE,
cred,
transport_type=TransportType.AmqpOverWebsocket,
) as client:
async with client.get_queue_sender(SERVICE_BUS_QUEUE_NAME) as sender:
print("=================== Disconnect network now ===================")
await asyncio.sleep(15)
print("=================== Sending... ===================")
await sender.send_messages(ServiceBusMessage('{"ignoreMe":true}'))
asyncio.run(test(), debug=True)
Expected behaviour
When a connection attempt fails because the network has disappeared, all aiohttp.ClientSession objects created by the Service Bus transport should be closed. There should be no "Unclosed client session" errors.
Actual behaviour
Multiple aiohttp.ClientSession instances remain unclosed after the failed connection/retry sequence.
In my reproduction, four unclosed client sessions are reported.
The issue appears to occur during the failed connection/retry path rather than because the application failed to close the Service Bus client.
Additional context
Using the legacy uamqp transport (uamqp_transport=True) eliminates the problem.
- 主要语言
- Python
- 星标
- 5.6k
- 派生
- 3.4k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 213
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/azure-sdk-for-python 的其他 Issue
-
[Teams Chatbot]: Clarify Python dev-feed publication from a branch versus PyPI release可能已有人在做 @jianingwang123 于 9 天前认领。 未关闭customer-reported question
难度 2/5 1-3 小时 新手友好度 62/100
Azure/azure-sdk-for-python#49548 · 1 条评论 · 2 个 reaction · 已指派 2 人 ·
维护者通常 1 天内回复
-
Client customer-reported Hosted Agents needs-team-attention question Service Attention
难度 2/5 1-3 小时 新手友好度 78/100
Azure/azure-sdk-for-python#49477 · 6 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
azure-ai-evaluation: a content-harm score of 0 (no harm) is parsed as NaN in _parse_content_harm_response (numeric branch uses 0 < x instead of 0 <= x)可能已有人在做 @pujitha24 于 25 天前认领。 未关闭Evaluation Service Attention
难度 2/5 1-3 小时 新手友好度 84/100
Azure/azure-sdk-for-python#49190 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
Azure/azure-sdk-for-python#49183 · 1 个 reaction ·
维护者通常 1 天内回复
-
azure-ai-evaluation: PromptyEvaluatorBase falls back to the first digit anywhere in the judge's reply, and the threshold turns a stray digit into a wrong pass/fail (15 evaluators)可能已有人在做 @wasim-builds 于 20 天前认领。 未关闭Evaluation Service Attention
难度 2/5 1-3 小时 新手友好度 75/100
Azure/azure-sdk-for-python#49153 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 Azure/azure-sdk-for-python 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
slavakurilyak/awesome-ai-agents#845 ·
维护者通常 1 天内回复
-
tests: pin that the atomic writers in utils/paths.py stage the temporary file in the target's directory可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭difficulty:2 enhancement good first issue
难度 1/5 1-3 小时 新手友好度 92/100
MakazhanAlpamys/Soup#2178 ·
维护者通常 1 天内回复
-
[BUG] dcg.waggr permutation p-values are folded twice, so near-zero scores get the smallest p-values未关闭
难度 2/5 1-3 小时 新手友好度 75/100
scverse/rapids-singlecell#854 ·
维护者通常 1 天内回复
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGL可能已有人在做 @ninglinLiu 今天认领。 未关闭area:frontend backend:slang bug direction:input
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
random_elements(unique=True) on an OrderedDict: ZeroDivisionError once only zero weights remain, AssertionError with use_weighting=False可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 13 天内回复