spark kafka directstream java.io.EOFException: Received -1 when reading from channel, socket has lik

spark directstream 消费kafka数据的时候出现报错
java.io.EOFException: Received -1 when reading from channel, socket has likely been closed.
spark kafka directstream java.io.EOFException: Received -1 when reading from channel, socket has lik_第1张图片
val brokers = “hadoop:2181”
val kafkaParams = Map[String,String](“metadata.broker.list” -> brokers,
//smallest : 自动把offset设为最早的offset数据;
//largest : 自动把offset设为最新的offset数据;
“auto.offset.reset” -> “smallest”,
“serializer.class” -> “kafka.serializer.StringDecoder”)
val lines = KafkaUtils.createDirectStreamString,String,StringDecoder,StringDecoder.map(_._2)

问题就在于brokers
brokers是kafka生产者的端口,错在填了ZK的端口,所以无法发现生产数据,所以报错是里边没数据。
只要把brokers="hadoop:9092"就可以正常找到生产数据,并且可以正常消费了。

如果还是有问题就要看看kafka配置文件,server.properties
添加这个配置就好
listeners=PLAINTEXT://:9092
或者直接添加
port=9092
都可以

你可能感兴趣的:(大数据)