-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Connection to firestore is getting lost after sometime with a message about "invalid authentication credentials". #130
Comments
Hi @skywritergr When you say 'some time' before the credentials cease working, how long is that? Minutes, an hour, a day? |
In the latest example I can see a request working as expected at: |
@skywritergr Can you try updating |
Thanks for your reply @tseaver, I have now updated to version 1.9.0. Here is what I get after doing
|
Hmm, |
The
The requirements.txt exports gives me the following list: https://pastebin.com/hLCRTFpY |
I thought that the problem might have solved itself by updating the library. It was working fine for a few days now. Today it happened again. Same error as before. What I was doing:
|
I also see this problem with the python client. I have several long-running download scripts, and they fail after one hour with this error. I assume that the token is expiring? I am going to try automatically expiring and re-creating the client every 30 minutes and see if that helps... |
I have a wrapper I use around the Firestore client that automatically does the oauth refresh dance. It does a bunch of other stuff you probably don't want/need but you can see the auth workflow here https://github.com/paulharter/fam/blob/master/src/fam/database/firestore.py |
One thing stood out: Cloud Run has a max time of 3600 seconds (an hour), and @skywritergr you state it was fine for an hour. But I'd imagine the request would time out at that point. Or are the requests smaller requests over the time period? The sample included is a streaming call I assumed was very large. Also, when |
I admit that I paused it for maybe a couple of minutes. Not longer than that. Also the request isn't very large at all. The data are actually the IMDB file document ingested into firebase. So the Python request is a streaming call into firebase that searches for a movie. It's the dataset from here: https://www.imdb.com/interfaces/ (the ratings one I think) |
@skywritergr is that how long it is pausing in cloud run? Or is the pause there >60 minutes? |
Oh definitely more than 60 minutes on cloud run. This is a very low traffic website that might get 3-4 searches a day. |
I think auth needs to be refreshed every 60 minutes, and I believe what you are observing are the credentials used by the stream going stale. |
I saw your message in the other issue. Is the working assumption that the token refresh is happening in the middle of a streaming event and that fails to complete? I can see it happening somewhere in the beginning.
|
Hi @skywritergr if it's not too much trouble, could you enable gRPC logging and let us know what you see?
https://github.com/grpc/grpc/blob/master/TROUBLESHOOTING.md This was suggested by a gRPC engineer for tracking down the root cause: https://groups.google.com/g/grpc-io/c/5rOhCcqyHng |
Hi - could the original author (@skywritergr) or a repo maintainer look this over please? I am not very familiar with Firestore and may have ended up making some incorrect assumptions. Re-reading the original post it sounds like each end user request results in a new, separate call to firestore. Is this correct, or does the
If this sounds like the correct flow of events, this looks very similar to googleapis/python-api-core#223. Notes for reproducing: To make sure the container goes into "idle mode" instead of shutting down, |
@skywritergr, a couple of observations.
|
We don't have enough info to continue debugging this, so I'm going to close it out. If the original author or anyone else is seeing an issue like this, can you open a new issue with repro steps? Thank you! |
Environment details
google-cloud-firestore
version: 1.6.2Steps to reproduce
This is a very weird one to reproduce. What is happening is that I deploy my docker container to Google Cloud Run and for some time everything works fine. I do successfully connect to the Firestore and retrieve data. After some point though things stop working and I get a
Exception: 401 Request had invalid authentication credentials.
So very broad steps would be
Code example
Stack trace
I have been trying to get to the bottom of this but I honestly don't know where the error is. Some assumptions:
docker pause <container>
the connection worked fine after "awakening" the container. But that doesn't mean that this is how GCR works.initialize_app
on every API request that uses that resource (essentially moving the code insidefunction_A
) but that is obviously a hug hack and it makes the application complain that the app is already initialized.I would really appreciate any pointers.
The text was updated successfully, but these errors were encountered: