Closed matthieuEv closed 8 months ago
Right, missed that part in the spec, I'll have to add a reconnect mechanism.
I think i've seen the same error here with a possible solution
Hmm I've been thinkering with this but it is really hard to guarantee "exactly-once" delivery without pocketbase providing any message ids or allowing a new connection to reuse an old client id... I might have to give up on that and do it in a "best effort" kind of way.
Yeah i know. I looked at the js-sdk to see how they make the subscribe function but the way the python code works is not the same:
The connect()
method handles situations where multiple connections are attempted simultaneously. It creates a queue of promises (pendingConnects
) and only establishes the connection once, resolving all pending promises with the connection result.
A method hasUnsentSubscriptions()
is used to ensures that any new or changed subscriptions are submitted after reconnection.
The connectErrorHandler()
method now tracks the number of reconnect attempts (reconnectAttempts
) and implements a pre-defined exponential backoff strategy for reconnection attempts.
For the python code, I can see the error appening in:
#realtime.py Line 54
async with aconnect_sse(self._in.client, "GET", self.__base_sub_path__, timeout=900) as sse:
async for message in sse.aiter_sse():
...
Description
When I use the
subscribe
method of the package and run it in an infinite loop, if no modifications are made to the specified Collection/record_id within 10 minutes, I encounter the following error:httpx.RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read)
.Steps to reproduce
Using this test code:
I run the code and i wait for 5-10 mins.
Expected behavior
It should not Close the connection
[Optional] Stacktrace
Environment
WSL Version 2
Python 3.11.0rc1
PocketBase v0.21.3
0.8.3