-
Notifications
You must be signed in to change notification settings - Fork 1.4k
kafka.errors.NoBrokersAvailable exception when running producer example on Mac #1308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have the same problem on windows using Kafka 1.0.0 |
@vkroz what version of kafka-python / kafka brokers? Can you share the code snippet you used for confluent-kafka-python to connect? |
@jeffwidman It's just 2 lines of code in Python console as shown above. And apparently it has something to do with setup of specific cluster. When I'm trying to connect to another remote Kafka cluster it works fine. |
Are there differences between the server.properties of the two clusters? I'd start by checking the |
Here are server properties used to run 3-nodes cluster on localhost -- the one which is python client os failing to connect https://gist.github.com/vkroz/5ee7854448fdd96ab619a7f7380fa0c2 And these config are fully operations, cluster is accessible by Java producers/consumers and all standard Kafka tools. |
These look fine to me, nothing amiss. Can you share the snippet you use to connect using |
what does this show:
|
Version 1.3.5 of this library (which is latest on pypy) only lists certain API versions 0.8.0 to 0.10.1. So unless you explicitly specify api_version to be (0, 10, 1) the client library's attempt to discover the version will cause a NoBrokersAvailable error. an example from my code: producer = KafkaProducer(
bootstrap_servers=URL,
client_id=CLIENT_ID,
value_serializer=JsonSerializer.serialize,
api_version=(0, 10, 1)
) |
Although setting api_version may appear to fix a problem, this is a very wrong assessment:
The issue is not the version check, it is the TCP socket connection itself. If kafka-python can connect to a 1.0.0 broker it would still be identified as (0, 10, 1). The only thing you achieve by setting an api_version explicitly is you never actually try to open the TCP socket. But that probably just means that your connection issue will surface later when you try to send or receive messages. The deeper issue here is a real connection bug that I believe has to do with using all available dns lookup data during bootstrap. |
When I explicitly set the api_version, I am able to produce and consume events. |
I believe the underlying issue is related to handling multiple network interfaces. My mac, for example, shows three addrinfos for localhost:
The bootstrap and version check code currently only attempt connection on the first addrinfo returned, so if the broker is bound to a later addrinfo then the connection will fail. I fixed this in #1411 . |
May I please ask why explicitly setting the api_version always works for me but removing it always fails? It doesn't seem to me that the value of |
When you set |
That makes perfect sense, thank you! 👍 |
This is fixed on master |
@dpkp, I'm using 1.4.2 still encountering this issue. does master branch has been released? |
@dpkp same here, using 1.4.2 (installed on March 27, 2018) still getting the error on Macbook |
@dpkp Same problem, using 1.4.2, if version not specified, will raise the exception. |
I fixed this error with kafka config by adding 'custom kafka broker' with key-value: |
@jeffwidman hello, I am using kafka-python 1.4.2. |
jar349, specifying version number as you instructed solve 'NoBrokerAvailable' error. |
After investigating this issue for a while...
you need to use -
view this link for more details |
I am having the same problem using hosted Kafka (IBM Cloud) and 1.4.4 version of kafka-python. If I don't specify api_version, I can't connect to the consumer, and when I do my consumer does not receive any messages. |
I meet this problem in
It seems increasing this value |
@mrzhangboss works. |
How_ do you configure docker-compose
|
I had the same problem with kafka_2.12-2.1.0. osm_pm.1.kfdvv4by3ovs@osm-r4 | 02/13/2019 10:28:44 PM Connecting to Kafka server at kafka:9092 |
If you are using kafka-python library initialize your producer by specifying api_version. In my case it was "2"
|
- 참고: dpkp/kafka-python#1308 - 원인: kafka-python 라이브러리 문제 IPv4/IPv6 둘 다에 참조될 수 있는 이름을 썼을 때 브로커의 버전 체크 프로토콜이 동작하는데 실패하는 이슈
I'm going to close this, as it seems the underlying issue was fixed, and now it's just a catchall... but reading through the most recent comments, it seems most of those that have been traced to root causes are due to environment problems, not library bugs. If you are stumbling across this through searching, and can't figure it out, please open a new ticket instead of commenting on this one. |
Running single-node Kafka cluster on localhost on Mac (OS X 10.11.6)
Getting error on attempt to instantiate producer
getting error
Kafka is up, and running locally and producer from
confluent-kafka-python
works without issues. Any suggestions what to look for?The text was updated successfully, but these errors were encountered: