Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

aiohttp - incorrect handling of connection pooling with web sockets.

Open
#1,018 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
networking

Research direction

Start by reproducing the shared ClientSession example against two simultaneous TLS WebSocket connections on a pico 2 w running 1.25.0, then compare it with creating a session inside my_method. Done means connection pooling works for concurrent WebSocket connections without the MBEDTLS_ERR_SSL_BAD_INPUT_DATA exception.

Written by the indexing model from the issue text.

Description

Reading the official aiohttp documentation: https://docs.aiohttp.org/en/stable/client_reference.html

I optimized my code to have a single ClientSession within my app to take advantage of connection pooling

class My_class:
    _clientSession= aiohttp.ClientSession()

    async def my_method():
        async with self._clientSession.ws_connect(uri) as ws:
            await ws.receive_json()
            ...
            await ws.send_json(stuff)

my_method is invoked twice - to different web sockets, over TLS simultaneously.

I get randomly served with a Uncaught exception in callback: (-28928, 'MBEDTLS_ERR_SSL_BAD_INPUT_DATA').

Creating the ClientSession within my_method completely resolves the issue - but at the expense of connection pooling. I strongly suspect a racing condition tied to the pooling.

This is happening on a pico 2 w running 1.25.0

Dominant language
Python
Stars
2.9k
Forks
1.1k
Avg merge
7d 4h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from micropython/micropython-lib

All issues in micropython/micropython-lib

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.