gpt4 book ai didi

ssl - Kafka ssl Producer EOFException 而 Producer.send 来自 Cloud Foundry

转载 作者:太空宇宙 更新时间:2023-11-03 14:42:50 27 4
gpt4 key购买 nike

在 Cloud Foundry 中,我能够向非 ssl url(“kafkaURL:9092”)生成消息。但它不适用于 ssl url(“kafkaURL:9093”)。

Kafka 服务器版本 0.10.0.1 和客户端版本 0.10.0.0。

这是我使用的属性:

props.put(org.apache.kafka.clients.producer.ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, config.getString("obs_q_and_a_db.kafka.metadataBrokerList"))
props.put(org.apache.kafka.clients.producer.ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, classOf[StringSerializer])
props.put(org.apache.kafka.clients.producer.ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, classOf[StringSerializer])
props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL")
props.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, "mySslFolder/answersapi.kafka.client.keystore.jks")
props.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "sslTruststorePassword"))
props.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, "mySslFolder/answersapi.kafka.client.truststore.jks")
props.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "sslKeystorePassword")
props.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG, "sslKeyPassword")
props.setProperty("metadata.broker.list", "kafkaURL:9093"))
props.setProperty("serializer.class", serializerClass)
props.setProperty("message.send.max.retries", maxRetries.toString)
props.setProperty("request.required.acks", requiredAcks.toString)
props.setProperty("producer.type", producerType)
props.setProperty("batch.num.messages", batchNumMessages.toString)

在 kafka 服务器上的 Kafka shell 中使用相同的属性和相同的证书文件(truststore、keystore 文件)时,在 shell 中使用以下命令可以正常工作:

kafka-console-producer --broker-list kafkaURL:9093 --producer.config config  --topic myTopicName

这里是错误:

2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT java.io.EOFException
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at org.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:99)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.network.BlockingChannel.readCompletely(BlockingChannel.scala:129)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.network.BlockingChannel.receive(BlockingChannel.scala:120)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.producer.SyncProducer.liftedTree1$1(SyncProducer.scala:77)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(SyncProducer.scala:74)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.producer.SyncProducer.send(SyncProducer.scala:119)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.client.ClientUtils$.fetchTopicMetadata(ClientUtils.scala:59)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.producer.BrokerPartitionInfo.updateInfo(BrokerPartitionInfo.scala:82)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.producer.async.DefaultEventHandler$$anonfun$handle$1.apply$mcV$sp(DefaultEventHandler.scala:68)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.utils.CoreUtils$.swallow(CoreUtils.scala:79)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.utils.Logging$class.swallowError(Logging.scala:106)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.utils.CoreUtils$.swallowError(CoreUtils.scala:51)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.producer.async.DefaultEventHandler.handle(DefaultEventHandler.scala:68)
2017-01-18T12:03:29.78-0600 [APP/PROC/WEB/0]OUT at kafka.producer.Producer.send(Producer.scala:77)

最佳答案

我们的 Kafka 客户端代码版本:“0.9.0.1”在服务器移动到 0.10.0.1 时停止工作当我们将客户端代码更改为 0.10.0.0 时,我们仍然得到相同的 EOFileException当我们更换时它得到修复弃用类 kafka.producer.{KeyedMessage, Producer, ProducerConfig}分别使用新的 0.10.0 类 org.apache.kafka.clients.producer.{ProducerRecord, KafkaProducer, ProducerConfig}顺便说一句,旧的弃用类在指向非 SSL url 时工作正常,它们仅在指向安全的 Kafka URL 时失败

关于ssl - Kafka ssl Producer EOFException 而 Producer.send 来自 Cloud Foundry,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41819156/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com