, but unable to connect from my local client with this address.
A sample python code looks like this
import os
KAFKA_HOSTS = os.getenv("KAFKA_HOSTS", "localhost:9092")
TOPIC = 'test'
from kafka import KafkaProducer
import json
import time
producer = KafkaProducer(
bootstrap_servers=KAFKA_HOSTS,
value_serializer=lambda v: json.dumps(v).encode('utf-8')
)
data = {
"timestamp" : "2019-01-14T16:07:09.549963",
"ip" : "192.168.123.123",
"user" : "Maker01",
"activities" : "Login"
}
for i in range(5):
producer.send(TOPIC, data)
print("Sent data: {}".format(data))
time.sleep(1)
and I got the error below
Traceback (most recent call last):
File "/Users/local/.pyenv/versions/kafka/lib/python3.6/site-packages/kafka/conn.py", line 225, in connect
socket.SOCK_STREAM)
File "/Users/local/.pyenv/versions/3.6.1/lib/python3.6/socket.py", line 743, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "producer.py", line 8, in <module>
value_serializer=lambda v: json.dumps(v).encode('utf-8')
File "/Users/local/.pyenv/versions/kafka/lib/python3.6/site-packages/kafka/producer/kafka.py", line 334, in __init__
**self.config)
File "/Users/local/.pyenv/versions/kafka/lib/python3.6/site-packages/kafka/client_async.py", line 204, in __init__
self.config['api_version'] = self.check_version(timeout=check_timeout)
File "/Users/local/.pyenv/versions/kafka/lib/python3.6/site-packages/kafka/client_async.py", line 796, in check_version
self._maybe_connect(try_node)
File "/Users/local/.pyenv/versions/kafka/lib/python3.6/site-packages/kafka/client_async.py", line 324, in _maybe_connect
conn.connect()
File "/Users/local/.pyenv/versions/kafka/lib/python3.6/site-packages/kafka/conn.py", line 230, in connect
self._init_host, self._init_port, ex
socket.gaierror: getaddrinfo failed for bnm-kafka-headless.bitnami-kafka:9092, exception was [Errno 8] nodename nor servname provided, or not known. Is your advertised.listeners (calledadvertised.host.name before Kafka 9) correct and resolvable?
The same code actually run well if Kafka deployed on an EC2 instance.
Any idea about this issue? or where I am getting wrong
Hi,
I followed the instruction
, but unable to connect from my local client with this address.
A sample python code looks like this
and I got the error below
The same code actually run well if Kafka deployed on an EC2 instance.
Any idea about this issue? or where I am getting wrong