相关文章推荐
痛苦的米饭  ·  Process 類別 ...·  1 月前    · 
含蓄的酸菜鱼  ·  ChatGPT的底层逻辑 | 人人都是产品经理·  2 年前    · 
面冷心慈的西装  ·  MySQL中union和order ...·  2 年前    · 
捣蛋的上铺  ·  第 2 部分,将控制器添加到 ...·  2 年前    · 
胡子拉碴的小蝌蚪  ·  vue项目读取全局配置_51CTO博客_vu ...·  2 年前    · 
Code  ›  异常: 503拉取数据到Google Pub/Sub时无法连接到所有地址开发者社区
科技新闻 sub
https://cloud.tencent.com/developer/ask/sof/524430
还单身的松球
2 年前
首页
学习
活动
专区
工具
TVP
返回腾讯云官网
提问
问 异常: 503拉取数据到Google Pub/Sub时无法连接到所有地址
Stack Overflow用户
提问于 2021-07-23 04:46:44
EN

我使用的是Google发布/订阅教程中的示例代码。尝试发布消息时,抛出异常: 503无法连接到所有地址。我为服务帐户分配了发布/订阅发布者角色。直到前天,一切都很好。

从控制台或gcloud命令发布消息时没有问题。Cloud Functions是我的订阅。

以下是教程的链接:

https://cloud.google.com/pubsub/docs/samples/pubsub-publish-with-error-handler

以下是软件包及其版本:

cachetools==4.2.2 certifi==2021.5.30  charset-normalizer==2.0.3  
google-api-core==1.31.0  
google-auth==1.33.1  
google-cloud-pubsub==2.6.1  
googleapis-common-protos==1.53.0  
grpc-google-iam-v1==0.12.3  
grpcio==1.39.0  
idna==3.2  libcst==0.3.19  mypy-extensions==0.4.3  packaging==21.0  proto-plus==1.19.0  
protobuf==3.17.3  pyasn1==0.4.8  pyasn1-modules==0.2.8  pyparsing==2.4.7  pytz==2021.1  
PyYAML==5.4.1  requests==2.26.0  rsa==4.7.2  six==1.16.0  typing-extensions==3.10.0.0  
typing-inspect==0.7.1  urllib3==1.26.6  

以下是错误代码:

$ python publish-message.py
Failed to publish 10 messages.
Traceback (most recent call last):
  File "E:\gcp-pubsub-cs\lib\site-packages\google\api_core\grpc_helpers.py", line 67, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "E:\gcp-pubsub-cs\lib\site-packages\grpc\_channel.py", line 946, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "E:\gcp-pubsub-cs\lib\site-packages\grpc\_channel.py", line 849, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "failed to connect to all addresses"
        debug_error_string = "{"created":"@1626984490.444000000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3009,"referenced_errors":[{"created":"@1626984490.444000000","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":398,"grpc_status":14}]}"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "E:\gcp-pubsub-cs\lib\site-packages\google\api_core\retry.py", line 188, in retry_target
    return target()
  File "E:\gcp-pubsub-cs\lib\site-packages\google\api_core\timeout.py", line 102, in func_with_timeout
    return func(*args, **kwargs)
  File "E:\gcp-pubsub-cs\lib\site-packages\google\api_core\grpc_helpers.py", line 69, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.ServiceUnavailable: 503 failed to connect to all addresses
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "E:\gcp-pubsub-cs\lib\site-packages\google\cloud\pubsub_v1\publisher\_batch\thread.py", line 268, in _commit
    response = self._client.api.publish(
  File "E:\gcp-pubsub-cs\lib\site-packages\google\pubsub_v1\services\publisher\client.py", line 613, in publish
    response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
  File "E:\gcp-pubsub-cs\lib\site-packages\google\api_core\gapic_v1\method.py", line 145, in __call__
    return wrapped_func(*args, **kwargs)
  File "E:\gcp-pubsub-cs\lib\site-packages\google\api_core\retry.py", line 285, in retry_wrapped_func
    return retry_target(
  File "E:\gcp-pubsub-cs\lib\site-packages\google\api_core\retry.py", line 203, in retry_target
    six.raise_from(
  File "<string>", line 3, in raise_from
google.api_core.exceptions.RetryError: Deadline of 60.0s exceeded while calling functools.partial(<function _wrap_unary_errors.<locals>.error_remapped_callable at 0x000002A99F2BF0D0>, topic: "projects/stream-analytics-21/topics/twitter-stream"
messages {
  data: "0"
messages {
  data: "1"
messages {
  data: "2"
messages {
  data: "3"
messages {
  data: "4"
messages {
  data: "5"
messages {
  data: "6"
messages {
  data: "7"
messages {
  data: "8"
 
推荐文章
痛苦的米饭  ·  Process 類別 (System.Diagnostics) | Microsoft Learn
1 月前
含蓄的酸菜鱼  ·  ChatGPT的底层逻辑 | 人人都是产品经理
2 年前
面冷心慈的西装  ·  MySQL中union和order by一起使用的方法 - PC君 - 博客园
2 年前
捣蛋的上铺  ·  第 2 部分,将控制器添加到 ASP.NET Core MVC 应用 | Microsoft Learn
2 年前
胡子拉碴的小蝌蚪  ·  vue项目读取全局配置_51CTO博客_vue 全局
2 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号