微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

“处理组件发布订阅错误:组件发布订阅的初始化超时在 5 秒后超出”

如何解决“处理组件发布订阅错误:组件发布订阅的初始化超时在 5 秒后超出”

我在我的 .net 核心微服务中使用 DAPR 和 Docker。 我在 docker-compose.yml 中做了以下配置来运行 broker 和 dapr pubsub 配置。

PUBSUB.yml

apiVersion: dapr.io/v1alpha1
kind: Component
Metadata:
  name: pubsub
  namespace: default
spec:
  type: pubsub.kafka
  version: v1
  Metadata:
      # Kafka broker connection setting
    - name: brokers
      value: local:9092
    - name: authrequired
      value: "false"
    - name: maxMessageBytes
      value: 1024

和 Dockercompose.yml

  zookeeper:
     image: confluentinc/cp-zookeeper:6.1.1
     ports:
      - "2181:2181"
     environment:
      ZOOKEEPER_CLIENT_PORT: 2181
  broker:
    image: confluentinc/cp-kafka:6.1.1
    hostname: broker
    container_name: broker
    depends_on:
      - zookeeper
    ports:
      - "29092:29092"
      - "9092:9092"
      - "9101:9101"
      - "9090:9090"
    environment:
      KAFKA_broKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_LISTENER_Security_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      KAFKA_JMX_PORT: 9101
      KAFKA_JMX_HOSTNAME: localhost

我的 dapr 车没有在本地环境中初始化,其抛出错误如下

图片

错误


time="2021-04-12T07:05:26.9278616Z" level=info msg="starting Dapr Runtime -- version 1.0.0 -- commit 6314733" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.runtime type=log ver=1.0.0

time="2021-04-12T07:05:26.9282174Z" level=info msg="log level set to: info" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.runtime type=log ver=1.0.0

time="2021-04-12T07:05:26.9317538Z" level=info msg="metrics server started on :9090/" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.metrics type=log ver=1.0.0

time="2021-04-12T07:05:26.9339347Z" level=info msg="loading default configuration" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.runtime type=log ver=1.0.0

time="2021-04-12T07:05:26.9349457Z" level=info msg="standalone mode configured" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.runtime type=log ver=1.0.0

time="2021-04-12T07:05:26.9350359Z" level=info msg="app id: monitoringapi" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.runtime type=log ver=1.0.0

time="2021-04-12T07:05:26.9354469Z" level=info msg="mTLS is disabled. Skipping certificate request and tls validation" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.runtime type=log ver=1.0.0

time="2021-04-12T07:05:26.9384313Z" level=info msg="local service entry announced: monitoringapi -> 172.28.0.11:37301" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.contrib type=log ver=1.0.0

time="2021-04-12T07:05:26.9385462Z" level=info msg="Initialized name resolution to standalone" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.runtime type=log ver=1.0.0

time="2021-04-12T07:05:32.3047616Z" level=fatal msg="process component pubsub error: init timeout for component pubsub exceeded after 5s" app_id=monitoringapi instance=43a8c7996e98 scope=dapr.runtime type=log ver=1.0.0

请帮我解决这个问题

解决方法

这是通过简单的配置解决了这个问题 enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。