Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

AmqpOverWebsocket leaks aiohttp.ClientSession instances when network disconnects during send_messages()

Cerrado
#49,131 1 comentario 1 reacción 0 asignados Ver en GitHub

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

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

Service Attention Service Bus

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

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Azure/azure-sdk-for-python

Todos los issues de Azure/azure-sdk-for-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.