title: Python firebase_admin hangs when connecting to firestore emulator
body: <p>I am unable to connect to firestore emulator from python. Connecting and writing documents to a real project works fine, but when setting the env. variable &quot;FIRESTORE_EMULATOR_HOST&quot; the set-function never resolves. The code:</p>
  <pre><code>os.environ[&quot;FIRESTORE_EMULATOR_HOST&quot;]=&quot;localhost:8081&quot;
  os.environ[&quot;GCLOUD_PROJECT&quot;]=&quot;my_project&quot;
  cred = credentials.Certificate('./firebase_cert.json')
  
  default_app = firebase_admin.initialize_app(cred)
  db = firestore.client()
  
  doc_ref = db.collection(u'test').document()
  doc_ref.set({
      u'hello': &quot;test&quot;
  })
  
  print(&quot;Document stored successfully.&quot;)
  </code></pre>
  <p>My firebase.json:</p>
  <pre><code>{
      &quot;emulators&quot;: {
          &quot;firestore&quot;: {
             &quot;port&quot;: 8081
            },
           &quot;ui&quot;: {
           &quot;enabled&quot;: true
       } }
    }
  </code></pre>
  <p>What could cause this?</p>
  <p>UPDATE:
  I tried different things to figure out if this is a port issue and got the following in firebase-debug.log.</p>
  <ol>
  <li><p>Set port to 8080 in firebase.json:</p>
  <p>Jul 08, 2021 12:42:50 PM io.gapi.emulators.netty.NotFoundHandler handleRequest
  INFO: Unknown request URI: /app/agents/protocols</p>
  </li>
  <li><p>Set port to 8081 in firebase.json:</p>
  <p>Jul 08, 2021 12:42:00 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
  INFO: Detected non-HTTP/2 connection.</p>
  </li>
  <li><p>Not set port at all in firebase.json (force default port)</p>
  <p>Jul 08, 2021 12:46:06 PM io.gapi.emulators.netty.NotFoundHandler handleRequest
  INFO: Unknown request URI: /app/agents/protocols</p>
  </li>
  </ol>
  <p>I dug into the google cloud package and found that the code at least executes until this point (line 821 in venv/Lib/site-packages/google/cloud/firestore_v1/services/firestore/client.py):</p>
  <pre><code>response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
  </code></pre>