vaphes / pocketbase

PocketBase client SDK for python
https://pypi.org/project/pocketbase/
MIT License
359 stars 41 forks source link

SSE thread will die silently #78

Open joshmcculloch opened 10 months ago

joshmcculloch commented 10 months ago

Currently any exception in the SSEClient/Eventloop will result in the the thead exiting. In my testing I see the http.ReadTimeout exception when the connection to the server is dropped. There is no indication to the subscriber that new events are no longer getting through.

I'm happy to help with the fix, but I'm looking for some guidence on how to push the event through to the calling code and how the situation should be resolved.

To patch this for my appication I have just caught the exception, slept, and allowed a new connection to be established. Perhaps this was always the intention as there is already a while loop that causes the reconnect. Link to my change

m29h commented 10 months ago

Thank you for looking into this. Your solution looks fine for the situation where the client looses connection because of e.g. a temporary network issue.

However there is a second situation where the server loses the client due to e.g. an restart/update of the pocketbase server or server side timeout.

In this case the client would have to reissue the RealtimeService._submit_subscriptions() logic to the server so that the server gets again the actual subscriptions...

Currently you would end up in a kind of infinite reconnecting attempt loop if the server looses track of the client...