骆驼卡夫卡java.io.EOFException-NetworkReceive.readFromReadableChannel

时间:2018-06-22 14:32:42

标签: java apache-kafka apache-camel activemq kerberos

我正在尝试使用 Kerberos 从ActiveMQ-Camel桥向Kafka(Cloudera)生成消息。

  • ActiveMQ v5.15.4
  • 骆驼:2.21.1
  • Kafka客户:1.1.0
  • 服务器版本:Apache / 2.4.6(CentOS)

camel.xml片段是:

<log message="Started The Producer Route" />
<to uri="kafka://10.100.70.00:9092?topic=MyEvents.s1.v1&amp;brokers=10.100.70.00:9092&amp;requestTimeoutMs=305000&amp;retries=3&amp;keySerializerClass=org.apache.kafka.common.serialization.ByteArraySerializer&amp;saslMechanism=GSSAPI&amp;serializerClass=org.apache.kafka.common.serialization.ByteArraySerializer&amp;securityProtocol=PLAINTEXT&amp;saslKerberosServiceName=kafka"/>

这是日志中的kafka客户端配置:

acks = 1
batch.size = 16384
bootstrap.servers = [10.148.70.74:9092]
buffer.memory = 33554432
client.id =
compression.type = none
connections.max.idle.ms = 540000
enable.idempotence = false
interceptor.classes = []
key.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer
linger.ms = 0
max.block.ms = 60000
max.in.flight.requests.per.connection = 5
max.request.size = 1048576
metadata.max.age.ms = 300000
metric.reporters = []
metrics.num.samples = 2
metrics.recording.level = INFO
metrics.sample.window.ms = 30000
partitioner.class = class org.apache.kafka.clients.producer.internals.DefaultPartitioner
receive.buffer.bytes = 65536
reconnect.backoff.max.ms = 1000
reconnect.backoff.ms = 50
request.timeout.ms = 305000
retries = 3
retry.backoff.ms = 100
sasl.jaas.config = null
sasl.kerberos.kinit.cmd = /usr/bin/kinit
sasl.kerberos.min.time.before.relogin = 60000
sasl.kerberos.service.name = kafka
sasl.kerberos.ticket.renew.jitter = 0.05
sasl.kerberos.ticket.renew.window.factor = 0.8
sasl.mechanism = GSSAPI
security.protocol = PLAINTEXT (**SASL_PLAINTEXT not supported**)
send.buffer.bytes = 131072
ssl.cipher.suites = null
ssl.enabled.protocols = [TLSv1.2, TLSv1.1, TLSv1]
ssl.endpoint.identification.algorithm = null
ssl.key.password = null
ssl.keymanager.algorithm = SunX509
ssl.keystore.location = null
ssl.keystore.password = null
ssl.keystore.type = JKS
ssl.protocol = TLS
ssl.provider = null
ssl.secure.random.implementation = null
ssl.trustmanager.algorithm = PKIX
ssl.truststore.location = null
ssl.truststore.password = null
ssl.truststore.type = JKS
    transaction.timeout.ms = 60000
    transactional.id = null
    value.serializer = class org.apache.kafka.common.serialization.ByteArraySerializer

日志级别:调试

Jaas文件:

KafkaClient {
    com.sun.security.auth.module.Krb5LoginModule required
    useKeyTab=true
    storeKey=true
    keyTab="./user.keytab"
    useTicketCache=false
    serviceName="kafka"
    principal=" Group/user@DOMAIN.LAN";
};

导出:

KAFKA_OPTS="-Djava.security.auth.login.config=/opt/activemq/conf/Jaas.conf"

我发送邮件时,会收到 DEBUG 级别的以下日志,并且邮件未传递:

    java.io.EOFException
        at org.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:124)[kafka-clients-1.1.0.jar:]
        at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:93)[kafka-clients-1.1.0.jar:]
        at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:235)[kafka-clients-1.1.0.jar:]
        at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:196)[kafka-clients-1.1.0.jar:]
        at org.apache.kafka.common.network.Selector.attemptRead(Selector.java:557)[kafka-clients-1.1.0.jar:]
        at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:495)[kafka-clients-1.1.0.jar:]
        at org.apache.kafka.common.network.Selector.poll(Selector.java:424)[kafka-clients-1.1.0.jar:]
        at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:460)[kafka-clients-1.1.0.jar:]
        at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:239)[kafka-clients-1.1.0.jar:]
        at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:163)[kafka-clients-1.1.0.jar:]
        at java.lang.Thread.run(Thread.java:748)[:1.8.0_171

INFO 级别,我仅在日志中看到此信息:

WARN  | [Producer clientId=producer-1] Bootstrap broker 10.100.70.00:9092 (id: -1 rack: null) disconnected | org.apache.kafka.clients.NetworkClient | kafka-producer-network-thread | producer-1

为什么会出现此错误?请帮忙!

1 个答案:

答案 0 :(得分:0)

此错误是由未经授权的用户向Kafka生成消息引起的。

可以通过验证密钥表文件作为先决条件来缓解此类问题:

  • 从密钥表文件klist -k -t <keytabFile>验证服务帐户名
  • 对Active Directory进行身份验证:kinit -k -t <keytabFile> <servicePrincipal>

没有任何错误。