【问题标题】:connection error with spring cloud kafka streamspring cloud kafka流的连接错误
【发布时间】:2019-03-12 16:22:25
【问题描述】:

我正在尝试在托管的 kafka 提供者身份验证类型之一是 SASL_SSL 上连接 kafka 流 下面是我的application.yml

spring:
  cloud:
    stream:
      kafka:
        binder:
          brokers: ark-01.srvs.cloudkafka.com:9094,ark-02.srvs.cloudkafka.com:9094,ark-03.srvs.cloudkafka.com:9094
          configuration:
            security:
              protocol: SASL_SSL
          jaas:
            loginmodule : org.apache.kafka.common.security.scram.ScramLoginModule required username="un" password="pwd"
        sasl :
          jaas :
            config : org.apache.kafka.common.security.scram.ScramLoginModule required username="un" password="pwd"

      bindings:
        greetings-in:
          destination: 2wow01xi-default
          contentType: application/json
        greetings-out:
          destination: 2wow01xi-default
          contentType: application/json

我无法连接请指教。

【问题讨论】:

  • 请编辑您的问题以将代码包含为文本,而不是图像

标签: apache-kafka kafka-consumer-api spring-cloud-stream


【解决方案1】:

...jaas.loginModule 需要大写 M

试试

    binder:
      jaas:
        loginModule : org.apache.kafka.common.security.scram.ScramLoginModule
        options:
          username: un
          password: pwd

【讨论】:

  • 这是一个关于如何配置安全性的工作示例。看配置。 github.com/spring-cloud/spring-cloud-stream-samples/tree/master/…
  • 它不起作用,因为我使用 kafka 作为服务并且安全协议如下 security.protocol: SASL_SSL
  • javax.security.auth.login.LoginException: KrbException: 找不到默认领域
  • @gary-russell 任何帮助
  • the kafka documentation。直接使用本机 kafka-clients 创建消费者(或生产者)(无 Spring)。一旦你开始工作,将 kafka 打印的 INFO 日志与图片中带有 Spring 的日志进行比较;如果你想不通;编辑您的问题以显示两个日志。
【解决方案2】:

我已经使用以下配置解决了上述问题@gary-russell 请确认其方法是否正确

    spring:
        cloud.stream:
           bindings:
    greetings-in:
      destination: ms-dev-logs
      contentType: application/json
      binder: kafka1
    greetings-out:
      destination: ms-dev-logs
      contentType: application/json
      binder: kafka1
  binders:
    kafka1: 
    type: kafka
    environment:
        spring:
          cloud:
            stream:
              kafka:
                binder.brokers: ipaddr:9092,ipaddr9092,ipaddr:9092
                streams :
                  binder :
                    configuration :
                      default.key.serde: org.apache.kafka.common.serialization.Serdes$StringSerde
                      default.value.serde: org.springframework.kafka.support.serializer.JsonSerde

  kafka.binder:
    configuration:
      security.protocol: SASL_PLAINTEXT
      sasl.mechanism: SCRAM-SHA-256
kafka:
  properties:
    sasl:
      jaas:
        config : org.apache.kafka.common.security.scram.ScramLoginModule required username="usr" password="pws";

【讨论】:

    【解决方案3】:

    我发现问题出在 spring cloud kafka 库上,spring cloud 团队将在下一个版本中修复它,详细信息可以在

    找到

    https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/460

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-22
      • 1970-01-01
      • 2021-08-21
      • 1970-01-01
      • 2021-10-26
      • 1970-01-01
      • 2019-03-19
      • 1970-01-01
      相关资源
      最近更新 更多