You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, our development docker-compose file configures Kafka to use only a single advertised listener. This listener is used both for the internal communication inside Docker and for the communication with the outside world – our app. The only way to use this listener is to create a hosts entry for kafka pointing to 127.0.0.1 to mimic the internal Docker environment.
This is a mere workaround and there is a better way to configure the advertised listeners: to have one for the internal communication and one for the external. Here is a nice, understandable tl;dr for that.
Although this is the “correct” settings, there is still a problem with that. If Kafka is configured to use localhost as a hostname for external connection, the Inventory app cannot connect, failing with a NoBrokersAvailable error. At least on a Mac.
The reason is that localhost is a special hostname that resolves to several IP addresses. The version of kafka-python we use (1.3.5) doesn’t try all the addresses and fails fast if it cannot connect using the first in order.
This is a known issue and has been fixed already. However, the Kafka client package is listed under two different names on PyPI:
kafka, which we are using, does not receive updates any more and the last release 1.3.5 has the aforementioned bug.
kafka-python with the latest version being 1.4.6 where the bug is already fixed
When the newer version is used, it is possible to connect to Kafka using the localhost advertised listener.
Steps to reproduce:
Deploy the fixed dev.ymldocker-compose bundle. docker-compose -f dev.yml up
Make sure you have the 29092 port properly forwarded to Docker and possibly Docker-machine. Following Python code can help:
Currently, our development docker-compose file configures Kafka to use only a single advertised listener. This listener is used both for the internal communication inside Docker and for the communication with the outside world – our app. The only way to use this listener is to create a hosts entry for kafka pointing to 127.0.0.1 to mimic the internal Docker environment.
This is a mere workaround and there is a better way to configure the advertised listeners: to have one for the internal communication and one for the external. Here is a nice, understandable tl;dr for that.
Although this is the “correct” settings, there is still a problem with that. If Kafka is configured to use localhost as a hostname for external connection, the Inventory app cannot connect, failing with a NoBrokersAvailable error. At least on a Mac.
The reason is that localhost is a special hostname that resolves to several IP addresses. The version of kafka-python we use (1.3.5) doesn’t try all the addresses and fails fast if it cannot connect using the first in order.
This is a known issue and has been fixed already. However, the Kafka client package is listed under two different names on PyPI:
When the newer version is used, it is possible to connect to Kafka using the localhost advertised listener.
Steps to reproduce:
docker-compose -f dev.yml up
If the steps above don’t work for you, please drop a comment.
The text was updated successfully, but these errors were encountered: