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

Kafka Golang客户端无法连接到消息中心服务,go,apache-kafka,message-hub,Go,Apache Kafka,Message Hub,这是我正在运行的代码片段: 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(

这是我正在运行的代码片段:

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\n", err)
    os.Exit(1)
}
基本上,这可以在一台机器上成功运行,但不能在另一台机器上运行。我在不工作的机器上收到的错误如下:

'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:'

不确定此问题是否可以链接到此问题:。。。不要这样认为,因为确切的代码在一台机器上运行,而不是在另一台机器上运行。感谢您的帮助

消息中心需要TLS v.1.2

从错误消息中,很可能是两台机器上使用的tls版本不同

librdkafka提到了属性
ssl.cipher.suites
对于C或节点客户机,我从不需要设置它

如果您使用的是Mac,请确保librdkafka使用的是与Homebrew一起安装的openssl库,而不是Apple提供的。 在我的Mac上,我在导出后编译librdkafka

CPPFLAGS=-I/usr/local/opt/openssl/include
LDFLAGS=-L/usr/local/opt/openssl/lib