firebase-admin-python: Firestore: what possible cause of this exception: InternalServerError: 500 Received RST_STREAM with error code 0

[READ] Step 1: Are you in the right place?

  • For issues or feature requests related to the code in this repository file a Github issue.
    • If this is a feature request make sure the issue title starts with “FR:”.
  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general Firebase discussion, use the firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Ubuntu 18.04 + openerp 7___
  • Firebase SDK version: _____
  • Library version: _from pip freeze: firebase-admin==2.16.0 funcsigs==1.0.2 future==0.16.0 futures==3.2.0 gax-google-logging-v2==0.8.3 gax-google-pubsub-v1==0.8.3 gcloud==0.18.3 gdata==2.0.18 google-api-core==1.9.0 google-auth==1.6.3 google-cloud==0.34.0 google-cloud-core==0.29.1 google-cloud-firestore==0.32.1 google-cloud-storage==1.15.0 google-gax==0.16.0 google-resumable-media==0.3.2 googleapis-common-protos==1.5.9 grpc-google-logging-v2==0.11.1 grpc-google-pubsub-v1==0.11.1
  • Firebase Product: firestore___ (auth, database, storage, etc)

[REQUIRED] Step 3: Describe the problem

I’m developing a system to store orders into openerp that came from a mobile app. So I’ve integrated a firestore listener on a query snapshot on “orders” collection, BookingAppFirestore.uniqdb.collection('orders') .where('new_order', '==', True) .where('nxscm_order_id', '==', None) .on_snapshot(self.new_orders_on_snapshot)

Sometimes during the executions of my proofs I get this exception when an order is wrote on firestore and is received from the listener.

Steps to reproduce:

What happened? How can we make the problem occur? This could be a description, log/console output, etc.

the exception trace from openerp log system

Exception in thread Thread-OnRpcTerminated:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/nix/Sviluppo/venvs/odoo-dev/local/lib/python2.7/site-packages/google/cloud/firestore_v1/watch.py", line 290, in close
    raise reason
InternalServerError: 500 Received RST_STREAM with error code 0

2019-04-26 10:00:50,011 9102 INFO ? google.cloud.firestore_v1.watch: RPC termination has signaled manager shutdown.
2019-04-26 10:00:50,011 9102 ERROR db_dev google.api_core.bidi: Thread-ConsumeBidirectionalStream caught unexpected exception <_Rendezvous of RPC that terminated with:
	status = StatusCode.INTERNAL
	details = "Received RST_STREAM with error code 0"
	debug_error_string = "{"created":"@1556272850.010768238","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1095,"grpc_message":"Received RST_STREAM with error code 0","grpc_status":13}"
> and will exit.
Traceback (most recent call last):
  File "/home/nix/Sviluppo/venvs/odoo-dev/local/lib/python2.7/site-packages/google/api_core/bidi.py", line 543, in _thread_main
    response = self._bidi_rpc.recv()
  File "/home/nix/Sviluppo/venvs/odoo-dev/local/lib/python2.7/site-packages/google/api_core/bidi.py", line 454, in recv
    return self._recoverable(self._recv)
  File "/home/nix/Sviluppo/venvs/odoo-dev/local/lib/python2.7/site-packages/google/api_core/bidi.py", line 413, in _recoverable
    raise exc
_Rendezvous: <_Rendezvous of RPC that terminated with:
	status = StatusCode.INTERNAL
	details = "Received RST_STREAM with error code 0"
	debug_error_string = "{"created":"@1556272850.010768238","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1095,"grpc_message":"Received RST_STREAM with error code 0","grpc_status":13}"
>
2019-04-26 10:00:50,011 9102 INFO db_dev google.api_core.bidi: Thread-ConsumeBidirectionalStream exiting
// TODO(you): code here to reproduce the problem

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 36 (2 by maintainers)

Most upvoted comments

I found this hacky fix that works for now. I don’t like it, but there does not seem to currently be a better way of dealing with the issue:

https://stackoverflow.com/questions/55876107/how-to-detect-realtime-listener-errors-in-firebase-firestore-database

Thanks for trying the new version. Sorry this didn’t fix things up for you, I’ll reach back out to the backend folks for more ideas.

Investigative work is being done internally to track down why this is happening and what will be a safe fix to it.

As of right now I believe we have been able to reproduce the behavior with a python code base and are now determining the appropriate fix.

@gbonline @toby thanks for the details, I’ll get back to you when I have more info from the backend team.

@seanpmaddox Hello, this issue (and the related issues linked to here) are the publicly accessible issues that are available at this time.

Unfortunately we don’t yet have a tested & verified solution we’re ready to release. We do have some of my Python expert colleagues as well as gRPC experts and folks from the backend team working on coming up with a solution we’ll be happy with. There are a few options we’re looking at, but due to the length of time it takes to reproduce progress getting the solution to users is slow.

When we have a proposed solution available, it should be linked to this issue so this is a good place to keep an eye on things.

I’ve tried using the firebase realtime db with a listener instead firestore. With a simple program in which the listener is activated on a path, well after exact 60 minutes , the listener has received an event without there being an access to the database via console or other apps, and get all the childs of path.

update: also after 2h !

So there is a constant between the two systems firestore and firebase rt db: an event every 60 minutes after the activation of the listener!

the excerpt of the program

doc_ref = db.reference('/users')

def snap_mng(event):
    print(event.event_type)  # can be 'put' or 'patch'
    print(event.path)  # relative to the reference, it seems
    print(event.data)


doc_ref.listen(snap_mng)

start_time = time.time()

while True:
    # mostra
    time.sleep(1)
    elapsed_time = time.time() - start_time
    print time.strftime("%H:%M:%S", time.gmtime(elapsed_time))

Hi I confirm that the exception also happens to me 60 minutes after the subscription on_snapshot to collection

I’m also experiencing this issue both on my Kubuntu developer machine and my target platform Raspberry Pi. The problem is that when it happens I don’t receive any updates from Firestore anymore.

What would be the proper way of detecting this and recover from it?