Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

raise exceptions.from_grpc_error(exc) from exc google.api_core.exceptions.Unknown: None Stream removed

Open
#633 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
18/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
django, firebase, grpc, python
Domain
api, backend, databases

Research direction

No repository file, test, or entry point in firebase-admin-python is identified; the report points to the user's views.py, FirestoreManager.py, and Firestore query stream. Start by reproducing the idle-then-GET case with the listed package versions and inspect the Firestore streaming path. Done would require a confirmed SDK defect, a scoped fix, and a regression test.

Written by the indexing model from the issue text.

Description

needs-triage

I am developing a web project with Django.

I use Firebase's Firestore as my database.

Look at the views.py "def mail(request)" you can see I get data from firestore and render to 'mail.html'

And I go to http://127.0.0.1:8000/resource/mail/ is normal.

But if I do nothing lasts 5 minutes and reorganize this page,
I will get this error on my web.

I think my problem like this https://stackoverflow.com/questions/70446165/firestore-stream-removed-error-after-3-minutes-doing-nothing
,although it is .NET and my project is python.

Anyway the website is very normal at first,but after maybe 3~5 minutes it get error.

    Unknown at /resource/mail/
    None Stream removed
    Request Method:	GET
    Request URL:	http://127.0.0.1:8000/resource/mail/
    Django Version:	4.0.6
    Exception Type:	Unknown
    Exception Value:	
    None Stream removed
    Exception Location:	C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\grpc_helpers.py, line 144, in error_remapped_callable
    Python Executable:	C:\Users\USER\.conda\envs\Backstage\python.exe
    Python Version:	3.9.12
    Python Path:	
    ['C:\\Users\\USER\\Desktop\\官網+後台\\Backstage',
    'C:\\Users\\USER\\.conda\\envs\\Backstage\\python39.zip',
    'C:\\Users\\USER\\.conda\\envs\\Backstage\\DLLs',
    'C:\\Users\\USER\\.conda\\envs\\Backstage\\lib',
    'C:\\Users\\USER\\.conda\\envs\\Backstage',
    'C:\\Users\\USER\\.conda\\envs\\Backstage\\lib\\site-packages']
    Server time:	Fri, 05 Aug 2022 17:01:33 +0800


    Traceback Switch to copy-and-paste view
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\grpc_helpers.py, line 140, in error_remapped_callable
                return _StreamingResponseIterator( …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\grpc_helpers.py, line 66, in __init__
                    self._stored_first_result = next(self._wrapped) …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\grpc\_channel.py, line 426, in __next__
            return self._next() …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\grpc\_channel.py, line 826, in _next
                        raise self …
    Local vars
    The above exception (<_MultiThreadedRendezvous of RPC that terminated with: status = StatusCode.UNKNOWN details = "Stream removed" debug_error_string = "{"created":"@1659690093.393000000","description":"Error received from peer ipv4:172.217.163.42:443","file":"src/core/lib/surface/call.cc","file_line":967,"grpc_message":"Stream removed","grpc_status":2}" >) was the direct cause of the following exception:
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\django\core\handlers\exception.py, line 55, in inner
                    response = get_response(request) …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\django\core\handlers\base.py, line 197, in _get_response
                    response = wrapped_callback(request, *callback_args, **callback_kwargs) …
    Local vars
    C:\Users\USER\Desktop\官網+後台\Backstage\myproject\views\resource.py, line 36, in mail
        for doc in docs: …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\cloud\firestore_v1\query.py, line 273, in stream
            response_iterator, expected_prefix = self._get_stream_iterator( …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\cloud\firestore_v1\query.py, line 218, in _get_stream_iterator
            response_iterator = self._client._firestore_api.run_query( …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\cloud\firestore_v1\services\firestore\client.py, line 1237, in run_query
            response = rpc( …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\gapic_v1\method.py, line 154, in __call__
            return wrapped_func(*args, **kwargs) …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\retry.py, line 283, in retry_wrapped_func
                return retry_target( …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\retry.py, line 190, in retry_target
                return target() …
    Local vars
    C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\grpc_helpers.py, line 144, in error_remapped_callable
                raise exceptions.from_grpc_error(exc) from exc …
    Local vars

urls.py:

    from django.contrib import admin
    from django.urls import path
    from myproject.views import *

    urlpatterns = [
        path('admin/', admin.site.urls),
        path('signup/', signup,name='signup'),#註冊
        path('login/', login),#登入
        path('index/', index),#主頁
        path('tradeQuery/', tradequery),#交易狀態查詢
        path('resource/mail/', mail),#送禮系統


]

views.py:

    def mail(request):
      docs=FirestoreManager.getDocsWhereTime("BackendLog-Mail") 
      for doc in docs:
          print(doc.to_dict())
      return render(request, 'mail.html', locals())

FirestoreManager.py:

    def getDocsWhereTime(*args): # 傳入參數為 collection_name,start_time,end_time
      if len(args)>0:
          collection_name=args[0]
      if len(args)>1:
          start_time=args[1]
      else:
          start_time=datetime(2022,8,1).astimezone(timezone(offset=timedelta(hours=8)))
      if len(args)>2:
          end_time=args[2]
      else:
          end_time=datetime.now(tz=timezone(timedelta(hours=8)))
      docs = db.collection(collection_name).where("CreateTime", '>=', start_time).where("CreateTime", "<", end_time).stream()
      return docs

requirements.txt:

    Django==4.0.6
    firebase-admin==5.1.0
    google-api-core==2.8.2
    google-api-python-client==2.55.0
    google-auth==2.9.1
    google-auth-httplib2==0.1.0
    google-cloud-core==2.3.2
    google-cloud-firestore==2.6.0
    google-cloud-storage==2.4.0
    google-crc32c==1.3.0
    google-resumable-media==2.3.3
    googleapis-common-protos==1.56.4
    grpcio==1.47.0

cmd console:

    Internal Server Error: /resource/mail/
    Traceback (most recent call last):
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\grpc_helpers.py", line 140, in error_remapped_callable
        return _StreamingResponseIterator(
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\grpc_helpers.py", line 66, in __init__
        self._stored_first_result = next(self._wrapped)
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\grpc\_channel.py", line 426, in __next__
        return self._next()
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\grpc\_channel.py", line 826, in _next
        raise self
    grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
            status = StatusCode.UNKNOWN
            details = "Stream removed"
            debug_error_string = "{"created":"@1659690093.393000000","description":"Error received from peer ipv4:172.217.163.42:443","file":"src/core/lib/surface/call.cc","file_line":967,"grpc_message":"Stream removed","grpc_status":2}"
    >
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
        response = get_response(request)
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "C:\Users\USER\Desktop\官網+後台\Backstage\myproject\views\resource.py", line 36, in mail
        for doc in docs:
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\cloud\firestore_v1\query.py", line 273, in stream
        response_iterator, expected_prefix = self._get_stream_iterator(
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\cloud\firestore_v1\query.py", line 218, in _get_stream_iterator
        response_iterator = self._client._firestore_api.run_query(
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\cloud\firestore_v1\services\firestore\client.py", line 1237, in run_query
        response = rpc(
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\gapic_v1\method.py", line 154, in __call__
        return wrapped_func(*args, **kwargs)
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\retry.py", line 283, in retry_wrapped_func
        return retry_target(
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\retry.py", line 190, in retry_target
        return target()
      File "C:\Users\USER\.conda\envs\Backstage\lib\site-packages\google\api_core\grpc_helpers.py", line 144, in error_remapped_callable
        raise exceptions.from_grpc_error(exc) from exc
    google.api_core.exceptions.Unknown: None Stream removed
    [05/Aug/2022 17:01:33] "GET /resource/mail/ HTTP/1.1" 500 125693

Dominant language
Python
Stars
1.2k
Forks
359
Avg merge
3d 9h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-admin-python

All issues in firebase/firebase-admin-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.