'Error while connecting Kafka over local wifi network created using ESP8266
Context: I am trying to connect Kafka on a local WiFi network that I created using ESP8266 devices and SoftAP.
What I am Trying to Achieve: I want devices (Laptops connected with ESP8266 SoftAP) to send and receive messages between each other using Kafka on a local WiFi network that is not connected to the internet.
Problem: One of the devices in the network is a Raspberry Pi and I am running Kafka over it. The error I am getting is
[2022-05-09 14:54:43,622] WARN [Controller id=0, targetBrokerId=0] Error connecting to node :192.168.4.2:9092 (id: 0 rack: null) (org.apache.kafka.clients.NetworkClient)
java.net.UnknownHostException: :192.168.4.2: invalid IPv6 address
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1345)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1302)
at org.apache.kafka.clients.DefaultHostResolver.resolve(DefaultHostResolver.java:27)
at org.apache.kafka.clients.ClientUtils.resolve(ClientUtils.java:110)
at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.currentAddress(ClusterConnectionStates.java:511)
at org.apache.kafka.clients.ClusterConnectionStates$NodeConnectionState.access$200(ClusterConnectionStates.java:468)
at org.apache.kafka.clients.ClusterConnectionStates.currentAddress(ClusterConnectionStates.java:173)
at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:984)
at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:301)
at org.apache.kafka.clients.NetworkClientUtils.awaitReady(NetworkClientUtils.java:64)
at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:291)
at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:245)
at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:96)
[2022-05-09 14:54:43,622] INFO [Controller id=0, targetBrokerId=0] Client requested connection close from node 0 (org.apache.kafka.clients.NetworkClient)
some of the config/server.properties are as follow:
listeners=PLAINTEXT://:0.0.0.0:9092
advertised.listeners=PLAINTEXT://:192.168.4.2:9092
zookeeper.connect=localhost:2181
Solution 1:[1]
The error is saying that it's trying to use :192.168.4.2 as an IPv6 host, rather than an IPv4 address.
You need to remove the leading colon of that IP in your two listeners settings.
Kafka might be too much for a Raspberry Pi, depending on the model. Mosquito MQTT or NATS would be more lightweight.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | OneCricketeer |
