-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firebase db listener cannot handle with internet disconnetions #287
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Hi, currently trying to solve the problem, I realized that was missing the timeout option in the instantiation of the SSEClient class, and figured out the requests.get() inside SSEClient._connect() has no timeout and that why i get stuck with my code when my internet is disconnected. To avoid these types of problems when internet disconnect on requests.get() method, probrably because is an streamer its no have timeout but when there is no connections its cause stuck in code, we should pass timeout as options, timeout will close a perfecly working stream threads too.. but anyway we already open new connections when token expires in 1 hour, so we should set default timeout to 3600?
|
I think the first thing to try would be to pass the |
saying httpTimeout do you mean initializate_app ** kwargs? or requests.Session timeout options. |
Check these links to starts with: firebase-admin-python/firebase_admin/__init__.py Lines 52 to 55 in 4488f53
firebase-admin-python/firebase_admin/db.py Line 361 in 4488f53
firebase-admin-python/firebase_admin/db.py Line 783 in 4488f53
|
You're setting a |
yes i realized what i did and then i removed comment above, for now i am passing httptimeout to session.get() method, i dont know why if i set httptimeout as 10sec it throws timeout as expected but if i set 100sec it do not give a timeout
|
|
Here
and AuthorizedSession inherit from requests.Session, then i belive there is a timeout .
and i testing now i think this really works, when there is no connections this throw exceptions like NewConnectionError, ConnectionError, ReadTimeoutError , etc in time of timeout parameter, and not preventing from rest of the code execute. Im not sure about this.. but still working, and i would like you guide me in making test for those implementation, of course if you accept it is correctly implementation. |
The
|
I cant just pass throw KeepAuthSession ? |
I've been having a similar (?) issue and I was wondering if this is related. I have an a Python app in Google Cloud Run. That container is sometimes stopped (if not enough usage) I guess in a way that could classify as a disconnection of sorts. I am instantiating the firebase connection like so: from firebase_admin import firestore, initialize_app, credentials
cred = credentials.ApplicationDefault()
initialize_app(cred, {
'projectId': 'my-project-id-1234',
})
db = firestore.client()
def function_A:
...
data = db.collection(u'data').where(u'title', u'==', name).stream()
...
def function_B:
.... The weird thing is that my application is working fine for some time and then randomly starts failing. After catching the exception i see the following:
It looks very similar to what is being talked here. Is there a solution to this? |
@skywritergr you're using Firestore and therefore is unrelated to this issue. I'd suggest reporting directly at https://github.com/googleapis/python-firestore |
[READ] Step 1: Are you in the right place?
file a Github issue.
with the firebase tag.
google group.
of the above categories, reach out to the personalized
Firebase support channel.
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
db.reference().listen() hang all code, do not run the rest of code, if when during connection of listener get internet disconnected, or if streamming allready connected and get disconnected for more than 2~3min and reconnect, do not get any updates from firebase.
i was searching for the root of this problem, and realised SSEclient have timeout default set by 3000, and the Event class retry time is set by None. Im not sure about this but maybe this is the problem?
Steps to reproduce:
To simulate the error we can just pull the cable or simply disconnect the internet from the system, wait 2 minutes to 3 minutes to reconnect it, after the reconnection, update any end-point that the streamming is listening. We can notice that we will not receive any updates.
It is also possible to simulate it during the streaming connection opening disconnect the internet and wait 2 to 3 minutes again and reconnect. We will not receive any updates from the firebase, and it will also be noticed that when this occurs, the codes below the opening stream do not run even wait for long time.
Relevant Code:
class SSEClient(object):
'''SSE client implementation.'''
class Event(object):
'''Event represents the events fired by SSE.'''
// TODO(you): code here to reproduce the problem
The text was updated successfully, but these errors were encountered: