How do I view the full TCP packet that Apache Kafka produces?

女生的网名这么多〃 提交于 2021-02-08 10:01:18

问题


I am using Apache Kafka. I use KafkaProducer to produce data and KafkaConsumer to consume data. My config data is:

Properties props = new Properties();
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
props.put(ProducerConfig.CLIENT_ID_CONFIG, "DemoProducer");
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.IntegerSerializer");
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");

The consumer config is the same. How do I view the whole TCP packet details which are being sent and received by the producers and consumers?


回答1:


You can use tshark with a Kafka dissector already available.

sudo apt-get update
sudo apt-get install tshark
sudo tshark -V -i lo -o 'kafka.tcp.port:9092' -d tcp.port=9092,kafka -f 'dst port 9092'

More details here Using the kafka dissector in wireshark/tshark 1.12




回答2:


After you installed Wireshark, you must go to Edit->Prefrences or press Ctrl + Shift + P. In the new window open protocols tree and find Kafka in the list. After selecting Kafka you must set the Kafka broker port numbers(It's by default 9092). And Also check Show length for string and bytes fields in the protocol tree checkbox as shown in blew image:

and click ok to dismiss the window. And then you can view all Kafka APIs calls:



来源:https://stackoverflow.com/questions/38352631/how-do-i-view-the-full-tcp-packet-that-apache-kafka-produces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!