AmqpOverWebsocket leaks aiohttp.ClientSession instances when network disconnects during send_messages()
Maintainer thường phản hồi trong vòng 1 ngày
@EldertGrootenboer đang làm issue này rồi.
Từ ngày 23/9/2026.
- #49159 của @EldertGrootenboer — đang mở
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- azure, python
- Lĩnh vực
- backend, networking
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 5.6k
- Fork
- 3.4k
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 209
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/azure-sdk-for-python
-
EngSys
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Azure/azure-sdk-for-python#49614 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Teams Chatbot]: Clarify Python dev-feed publication from a branch versus PyPI releaseCó thể đã có người làm @jianingwang123 đã nhận 6 ngày trước. Đang mởcustomer-reported question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Azure/azure-sdk-for-python#49548 · 1 bình luận · 2 reaction · 2 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Client customer-reported Hosted Agents needs-team-attention question Service Attention
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Azure/azure-sdk-for-python#49477 · 6 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
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)Có thể đã có người làm @pujitha24 đã nhận 22 ngày trước. Đang mởEvaluation Service Attention
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Azure/azure-sdk-for-python#49190 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update CODEOWNERSĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Azure/azure-sdk-for-python#49183 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Azure/azure-sdk-for-python
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
521xueweihan/HelloGitHub#4063 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Vanilla-OS/apx-gui#112 ·
-
Devstral and Voxtral: section 5 fails in us-east-1 with 400 "Model does not support audio modality"Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws-samples/sample-per-model-bedrock#409 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DuckDB 2.0 breaks to_pyarrow_batchesCó thể đã có người làm @DG47 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ibis-project/ibis#12196 ·
Maintainer thường phản hồi trong vòng 1 ngày