来自 Cloud Foundry 的 Kafka ssl Producer EOFException while Producer.send
Kafka ssl Producer EOFException while Producer.send from Cloud Foundry
在 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 shell 使用时在 Kafka 服务器上使用相同的属性和相同的证书文件(信任库、密钥库文件)在 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(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.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
时失败
在 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 shell 使用时在 Kafka 服务器上使用相同的属性和相同的证书文件(信任库、密钥库文件)在 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(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.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
时失败