Skip to content
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

connect to docker-kafka from external client (using python) #37

Open
ugomariaguicciardini opened this issue Feb 22, 2017 · 5 comments
Open
Labels

Comments

@ugomariaguicciardini
Copy link

ugomariaguicciardini commented Feb 22, 2017

All,

Firstly let me apologize for the trivial question, but I am kafka newbie!

I am trying to run the docker-kafka container on a linux test server.
I am able to run the usage-quick-start example succesfully.

The second step is to try to connect to kafka container from a separate machine using Kafka Python. I cannot figure out how to make this scenario working.

In particular i started docker-kafka container using a-more-complex-local-development-setup putting as KAFKA_ADVERTISED_HOST_NAME and ZOOKEEPER_IP the public IP of the (docker) host machine. Unfortunately the container crashes after few seconds, from the log is evident it is not able to connect to zookeeper.
So i slightly changed the command line to:

docker run -d --name kafka --volume /home/cimino/kafka/ches/logs/:/logs --publish 9092:9092 --publish 7203:7203 --env KAFKA_ADVERTISED_HOST_NAME=docker-host-public-ip-here --link zookeeper:zookeeper ches/kafka

In this case the container is running, here is docker ps (PORTS column):

PORTS                                            
0.0.0.0:7203->7203/tcp, 0.0.0.0:9092->9092/tcp

But when i try to connect from an external client i got time out network connection.
Here is the python comand line i am using (may this is OT, but i am reporting for completeness):

from kafka import KafkaProducer
producer = KafkaProducer(bootstrap_servers='docker-host-public-ip-here:9092')
producer.send('foobar', b'some_message_bytes')

What am I doing wrong?

Thanks
UMG

@chengfish
Copy link

Same here. I am trying to use an external java client, and saw the similar issue.

@ches
Copy link
Owner

ches commented Mar 19, 2017

Sorry for delay in replying—I'll have to try to replicate this, but just to rule out a simple high-level possibility first: is there perhaps a firewall running on your Docker host machine that's getting in the way?

A simple check would be, from the client machine where you're trying to connect with the Python lib, does telnet <your Docker host address/IP> 9092 successfully connect? If not you may need to disable your firewall or allow the ports through.

@ches ches added the question label Mar 19, 2017
@subdavis
Copy link

subdavis commented Aug 8, 2017

For anyone troubleshooting in the future, it really helps to run a simple TCP listener and try to connect.

On the host machine, nc -l 9092 while the docker image is not running.
From the client where you are trying to connect telnet <docker host address> 9092

If you are unable to connect, the problem is not here.

@alejandrox1
Copy link

@ches this happens when running telnet:

$ telnet <docker host addrs> 9092
Trying <docker host addrs>...
Connected to <docker host addrs>.
Escape character is '^]'.
ruok
Connection closed by foreign host.

and the client still throws an error indicating no brokers are available.

Was there a fix for this issue?

@shaunc
Copy link

shaunc commented Jan 25, 2018

I'm getting the same thing... are you using a Mac? perhaps related to #26 (comment) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants