-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
I've just installed kafka and zookeeper on Windows 10 Home based on instructions at https://dzone.com/articles/running-apache-kafka-on-windows-os, and as per that page tested it using
kafka-console-producer.bat --broker-list localhost:9092 --topic test
and
kafka-console-consumer.bat --zookeeper localhost:2181 --topic test
which work fine.
Unfortunately, when I try to use kafka-python from jupyter, I run into problems:
First, trying to call
from kafka import KafkaConsumer
consumer = KafkaConsumer(api_version=(0,10))
gave an error
ERROR:kafka.conn:Connection attempt to <BrokerConnection host=localhost/::1 port=9092> timed out
ERROR:kafka.client:Unable to bootstrap from [('localhost', 9092, 0)]
Thinking it was an IPv6 issue (kafka itself uses ipv4 in its terminal output), I tracked down in the code debugger the place where the ::1 appeared and hard-wired it to use 127.0.0.1 instead.
That merely switched the error to
ERROR:kafka.conn:Connection attempt to <BrokerConnection host=localhost/127.0.0.1 port=9092> timed out
ERROR:kafka.client:Unable to bootstrap from [('localhost', 9092, 0)]
Stepping through the code, I tracked the failure down to line 289 of conn.py
elif ret not in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK, 10022)
In the original version (IPV6), the value of ret there is 10035 once and then alternates between 10035 (EWOULDBLOCK) and 10022 (WSAEINVAL), so 10035,10035,10022,10035,10022,10035,etc; if I force the address to 127.0.0.1, it is 10035 once, and then keeps repeating 10022.
Finally, if I try calling
producer = KafkaProducer(bootstrap_servers=['localhost:9092'],api_version=(0,10))
then in addition to the above error, I get
WARNING:kafka.conn:socket.inet_pton not available on this platform. consider pip install win_inet_pton
When I run pip install win_inet_pton and restart jupyter, that message doesn't go away.
Any idea what the matter could be?
Thanks a lot!