Comments (7)
I can (somewhat) confirm this bug. For me when pocketbase closes the connection (after 300 seconds without events as per documentation) the EventLoop just ends (without an exception).
The effect is no more messages are received as the client currently does not realize that the event loop was forcibly closed and also does not try to reconnect to the realtime endpoint.
from pocketbase.
@User00092 can you have a look at the PR to see if that solves your original issue?
from pocketbase.
@m29h
Unfortunately, that does not solve the issue. The exception that httpx raises results in self.kill
being set to true
. Changing self.kill = True
to print('httpx closed connection.')
, httpx closed connection.
was displayed, and I was still able to receive updates from the server. I don't quite understand how you unsubscribe, so I cannot implement <Object>.kill = True
for you. However, if possible, please do.
Here are the changes I made in pocketbase/services/utils/sse.py
:
line 8:
import time
line 90-100:
def run(self):
while not self.kill:
try:
for event in self._events():
if self.kill:
break
if event.event in self.listeners:
self.listeners[event.event](event)
time.sleep(0.5) # Remove some stress off the CPU
except Exception:
pass
from pocketbase.
@User00092 can you give the output of
pip show httpx
so that I can try to reproduce this with the same version. It seems that the exception is not triggered in all httpx
library versions...
from pocketbase.
@m29h of course, here is the information:
Name: httpx
Version: 0.23.3
Summary: The next generation HTTP client.
Home-page:
Author:
Author-email: Tom Christie <[email protected]>
License:
Location: ---\venv\Lib\site-packages
Requires: certifi, httpcore, rfc3986, sniffio
Required-by: pocketbase
from pocketbase.
I edited the run
function to better handle errors, along with the RemoteProtocolError
if raised. This allows other exceptions to be handled properly, while handling RemoteProtocolError
in a way that doesn't affect the program.
def run(self):
while not self.kill:
try:
for event in self._events():
if self.kill:
break
if event.event in self.listeners:
self.listeners[event.event](event)
time.sleep(1) # Remove some stress off the CPU (In the event there are multiple threads), also saving system memory.
except httpx.RemoteProtocolError:
pass
except Exception as e:
print(e) # Or raise it
self.kill = True
from pocketbase.
Name: httpx Version: 0.23.3
@User00092 just tried it again with the same version in my environment linux/python 3.11.3
explicitly installing httpx 0.23.3
and still do not get an exception.
The httpx documentation says remote protocol error means "The protocol was violated by the server" this is somewhat not intuitively what one would expect if the other side silently closes the connection.
Is your pocketbase instance maybe behind some reverse proxy or firewall that does something strange?
I digged a bit deeper and it turns out httpx
is nowhere raising a RemoteProtocolError
but only wrapping an exception that is incoming from the httpcore library. the httpcore library itself wraps the RemoteProtocolError
exception incoming from the h11 library.
Looking at the h11 repository i found this (closed) issue: python-hyper/h11#133 from Year 2021.
What version is your h11 library? If it is < 0.14.0 than maybe it helps to upgrade h11 to >=0.14.0
from pocketbase.
Related Issues (20)
- Expanding relation with Pocketbase version 1.13.1 leads to error? HOT 2
- Client Deserializes Record Values to `collection_id` Attribute HOT 2
- Custom Headers for PocketBase
- how to get user id after logging in user HOT 1
- get_first_list_item Not Work HOT 1
- unsubscribe does not work in RealtimeService
- creating LocalAuthStore with at an empty location leads to FileNotFoundError error in _storage_get()
- Trying to upload a single file record uploads of three files with wrong content instead
- confirmPasswortReset returns the wrong type
- AdminService delete + update methods do not work
- version 0.8.2 actually isn't in pypi HOT 1
- Typo in function argument for auth_with_oauth2 method
- TypeError when expanding relations. HOT 6
- Pocketbase v0.18 api change breaks SchemaField unmarshaling
- Subscribe example HOT 2
- Remove class variables HOT 3
- Incorrect last pocketbase version? HOT 1
- Support for protected files HOT 3
- Back-relation expand HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pocketbase.