You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python中Firebase Admin调用无响应问题排查求助

Firebase Admin Python连接Firestore无响应,报错StatusCode.UNAVAILABLE

问题详情

近期在Python中使用Firebase Admin操作Firestore,编写示例脚本如下:

import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore

cred = credentials.Certificate("./services.json")
options = {
    "databaseURL": 'https://not_revealing_my_url.com'
}
app = firebase_admin.initialize_app(cred, options)

client = firestore.client(app)
print(client.document("/").get())

已确认:

  • Firestore服务已激活
  • 从Firebase项目服务账号生成的services.json放在脚本同目录下

按文档说明脚本应正常运行,但实际执行时无响应,中断后抛出错误:

grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "failed to connect to all addresses; last error: UNKNOWN: ipv6:%5B::1%5D:8081: tcp handshaker shutdown"
        debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"failed to connect to all addresses; last error: UNKNOWN: ipv6:%5B::1%5D:8081: tcp handshaker shutdown", grpc_status:14, created_time:"2025-05-11T08:47:32.8676384+00:00"}"

解决方案

问题根因

本地环境之前使用过Firebase模拟器,Firebase Admin SDK会默认优先尝试连接模拟器,但此时模拟器未启动,导致连接超时无响应。

解决步骤

  1. 移除系统PATH环境变量中Firebase模拟器相关的路径条目
  2. 重新运行脚本,SDK将正常连接云端Firestore服务

内容的提问来源于stack exchange,提问作者ori raisfeld

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 04:12:13