dsorecdf78171 2017-05-17 23:43
浏览 117

Kafka Golang客户端无法连接到消息中心服务

This is a code snippet of what I'm running:

err := godotenv.Load()
  if err != nil {
    log.Fatal("Error loading .env file")
  }
broker := os.Getenv("BROKER")
topic := os.Getenv("TOPIC")
username := os.Getenv("USERNAME")
password := os.Getenv("PASSWORD")
calocation := os.Getenv("CALOCATION")

p, err := kafka.NewProducer(&kafka.ConfigMap{
    "metadata.broker.list": broker,
    "security.protocol":    "sasl_ssl",
    "sasl.username":        username,
    "sasl.password":        password,
    "sasl.mechanisms":      "PLAIN",
    "ssl.ca.location":      calocation,
    "api.version.request":  true})

if err != nil {
    fmt.Printf("Failed to create producer: %s
", err)
    os.Exit(1)
}

Basically, this runs successfully on one machine, but not another. The error that I'm receiving on the machine that isn't working is the following:

'SSL handshake failed: /SourceCache/OpenSSL098/OpenSSL098-52.40.1/src/ssl/s23_clnt.c:593: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version:'

Not sure if this issue could be linked to this issue: Why kafka-python fails to connect to Bluemix message hub service?... Don't think so as the exact code is running on one machine but not the other. Any help is appreciated!

  • 写回答

1条回答 默认 最新

  • dongshi1606 2017-05-18 00:51
    关注

    Message Hub requires TLS v.1.2.

    From your error message it may well be that the tls version used on the two machines differs.

    librdkafka mentions the property ssl.cipher.suites https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md I never had to set it, for C or node clients.

    If you're using a Mac, make sure that librdkafka is using the openssl library that is installed with Homebrew and not the on from Apple. On my Mac I compile librdkafka after having exported CPPFLAGS=-I/usr/local/opt/openssl/include LDFLAGS=-L/usr/local/opt/openssl/lib

    评论

报告相同问题?

悬赏问题

  • ¥15 如何实验stm32主通道和互补通道独立输出
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题