【发布时间】:2021-09-28 12:34:45
【问题描述】:
我正在尝试使用 Python 代码(在 Jupyter Notebook 中)在我的项目中访问 Google 的 Firestore,但由于某种原因,Python 程序永远不会完成。 还尝试在 Firestore 中创建文档,但随后出现此错误:
ServiceUnavailable: 503 DNS resolution failed for service: firestore.googleapis.com
我在 Firestore 中创建了一个服务帐户(ServiceAccount.json 包含设置)。这是我的代码:
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
cred = credentials.Certificate('ServiceAccount.json')
firebase_admin.initialize_app(cred)
db = firestore.client()
db.collection('company').add({'name': 'Test'})
只有最后一条语句失败。 这也被返回:
_InactiveRpcError Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\google\api_core\grpc_helpers.py in error_remapped_callable(*args, **kwargs)
65 try:
---> 66 return callable_(*args, **kwargs)
67 except grpc.RpcError as exc:
C:\ProgramData\Anaconda3\lib\site-packages\grpc\_channel.py in __call__(self, request, timeout, metadata, credentials, wait_for_ready, compression)
945 wait_for_ready, compression)
--> 946 return _end_unary_response_blocking(state, call, False, None)
947
C:\ProgramData\Anaconda3\lib\site-packages\grpc\_channel.py in _end_unary_response_blocking(state, call, with_call, deadline)
848 else:
--> 849 raise _InactiveRpcError(state)
850
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "DNS resolution failed for service: firestore.googleapis.com"
debug_error_string = "{"created":"@1632831473.221000000","description":"Resolver transient failure","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":1356,"referenced_errors":[{"created":"@1632831473.221000000","description":"DNS resolution failed for service: firestore.googleapis.com","file":"src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc","file_line":202,"grpc_status":14,"referenced_errors":[{"created":"@1632831473.221000000","description":"OS Error","file":"src/core/lib/iomgr/resolve_address_windows.cc","file_line":93,"os_error":"The specified class was not found.\r\n","syscall":"getaddrinfo","wsa_error":10109}]}]}"
>
The above exception was the direct cause of the following exception:
ServiceUnavailable Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\google\api_core\retry.py in retry_target(target, predicate, sleep_generator, deadline, on_error)
189 try:
--> 190 return target()
191
...
【问题讨论】:
-
如果我尝试检查
firestore.googleapis.com(Linux:whois firestore.googleapis.com)的 IP,则表明该地址不存在。也许他们改变了一些东西,它需要更新模块或文件.json。或者也许这只是服务器的暂时问题,您必须等待几天,它会再次工作。 -
当我 ping firestore.googleapis.com 时,我确实收到了回复:
C:\>ping firestore.googleapis.com Pinging firestore.googleapis.com [142.251.36.42] with 32 bytes of data: Reply from 142.251.36.42: bytes=32 time=21ms TTL=117 Reply from 142.251.36.42: bytes=32 time=26ms TTL=117 Reply from 142.251.36.42: bytes=32 time=18ms TTL=117 Reply from 142.251.36.42: bytes=32 time=18ms TTL=117 Ping statistics for 142.251.36.42: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 18ms, Maximum = 26ms, Average = 20ms -
但是我的 Python 代码仍然冻结(在 get() 的情况下)或者当我尝试创建数据时返回相同的错误。
标签: python google-cloud-firestore