micropython / micropython/micropython-lib
aiohttp - incorrect handling of connection pooling with web sockets.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.1k
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 3
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100