AmqpOverWebsocket leaks aiohttp.ClientSession instances when network disconnects during send_messages()
Los mantenedores suelen responder en 1 día
@EldertGrootenboer ya está trabajando en esto.
Desde el 23/9/2026.
- #49159 de @EldertGrootenboer — abierto
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- azure, python
- Área
- backend, networking
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 5.6k
- Forks
- 3.4k
- Merge medio
- 2 d 10 h
- PR fusionados (30 d)
- 209
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Azure/azure-sdk-for-python
-
EngSys
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Azure/azure-sdk-for-python#49614 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
[Teams Chatbot]: Clarify Python dev-feed publication from a branch versus PyPI releasePosiblemente ocupada @jianingwang123 la tomó hace 6 días. Abiertocustomer-reported question
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Azure/azure-sdk-for-python#49548 · 1 comentario · 2 reacciones · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
Client customer-reported Hosted Agents needs-team-attention question Service Attention
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Azure/azure-sdk-for-python#49477 · 6 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
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)Posiblemente ocupada @pujitha24 la tomó hace 22 días. AbiertoEvaluation Service Attention
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Azure/azure-sdk-for-python#49190 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Update CODEOWNERSAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Azure/azure-sdk-for-python#49183 · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de Azure/azure-sdk-for-python
Issues similares
-
[Bug] Unit tests reach real Bedrock call paths without patching the modelPosiblemente ocupada @proton0210 la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
aws-samples/sample-aws-genai-db-modernizer#1318 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
pyarrow-25.0.1-cp310-cp310-manylinux_2_28_x86_64.whl: 1 vulnerabilities (highest severity is: 5.3)AbiertoMend: dependency security vulnerability
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
capitalone/locopy#394 ·
-
[Bug] Unhandled ValueError terminates watchdog thread when GISRC value contains multiple colonsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
sdk-typescript: unquoted COPY globs in shell form are silently dropped from the image build contextAbiertobug javascript
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
ietf-tools/datatracker#11922 · 1 comentario ·
Los mantenedores suelen responder en 1 día