如下所述:https://issuetracker.google.com/issues/113672049
交叉贴在这里:https://github.com/GoogleCloudPlatform/google-cloud-python/issues/5879)
在使用Python中Google云函数的Firebase存储API时,我遇到了一个连接重置错误。在
部署的函数正在调用一个blob get,即
from firebase_admin import storage
def fn(request):
bucket = 'my-firebase-bucket'
path = '/thing'
blob = storage.bucket(bucket).get_blob(path)
故障是间歇性的;该功能的成功率约为90%。在
它似乎更有可能在部署后第一次调用函数时失败。在
您可能需要检查您正在创建的客户机数量。在
https://cloud.google.com/functions/docs/concepts/exec#network
请参阅此示例,其中他们只创建一次客户端并在函数中重用它:
https://cloud.google.com/functions/docs/bestpractices/networking#accessing_google_apis
云函数是无状态的,但可以重用以前调用的全局状态。这在tips和these docs中有解释。在
将全局状态与重试一起使用,应该会给您一个更健壮的函数:
相关问题 更多 >
编程相关推荐