AmqpOverWebsocket leaks aiohttp.ClientSession instances when network disconnects during send_messages()
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- azure, python
- Ambito
- backend, networking
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 5.6k
- Fork
- 3.4k
- Merge medio
- 2g 10h
- PR unite (30g)
- 209
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Azure/azure-sdk-for-python
-
EngSys
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Azure/azure-sdk-for-python#49614 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
[Teams Chatbot]: Clarify Python dev-feed publication from a branch versus PyPI releaseForse già presa @jianingwang123 l’ha presa 6 giorni fa. Apertacustomer-reported question
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Azure/azure-sdk-for-python#49548 · 1 commento · 2 reazioni · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
Client customer-reported Hosted Agents needs-team-attention question Service Attention
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Azure/azure-sdk-for-python#49477 · 6 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
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)Forse già presa @pujitha24 l’ha presa 22 giorni fa. ApertaEvaluation Service Attention
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Azure/azure-sdk-for-python#49190 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Update CODEOWNERSAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
Azure/azure-sdk-for-python#49183 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Azure/azure-sdk-for-python
Issue simili
-
Uninstall guide omits the CloudWatch log groups AWS CodeBuild creates for useCodeBuild pipelinesApertabug documentation
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
awslabs/visual-asset-management-system#552 ·
I maintainer di solito rispondono entro 1 giorno
-
netbox status: needs triage type: documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
netbox-community/netbox#23460 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
awslabs/threat-composer#362 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ansys/pyansys-common-mcp#213 ·
I maintainer di solito rispondono entro 3 giorni