edenhill / kcat

Generic command line non-JVM Apache Kafka producer and consumer
Other
5.43k stars 484 forks source link

I am trying to connect to a remote Kafka broker to consume, with -b host, but it tries locally #255

Closed nmarasoiu closed 4 years ago

nmarasoiu commented 4 years ago

I am trying to connect to a remote Kafka broker to consume, but it tries locally: Pls help me understand why, thanks,

(base) NicuMarasoius-MacBook-Pro-3:kafka nicu$ telnet 169.254.212.189 9092
Trying 169.254.212.189...
Connected to ovo4939mb.local.
Escape character is '^]'.
sdf
Connection closed by foreign host.
(base) NicuMarasoius-MacBook-Pro-3:kafka nicu$ kafkacat -C -b 169.254.212.189 -t t
% ERROR: Local: Broker transport failure: localhost:9092/1: Connect to ipv6#[::1]:9092 failed: Connection refused (after 1ms in state CONNECT)
(base) NicuMarasoius-MacBook-Pro-3:kafka nicu$ kafkacat -C -b 169.254.212.189:9092 -t t
% ERROR: Local: Broker transport failure: localhost:9092/1: Connect to ipv6#[::1]:9092 failed: Connection refused (after 1ms in state CONNECT)
(base) NicuMarasoius-MacBook-Pro-3:kafka nicu$ kafkacat -C -b "169.254.212.189:9092" -t t
% ERROR: Local: Broker transport failure: localhost:9092/1: Connect to ipv6#[::1]:9092 failed: Connection refused (after 1ms in state CONNECT)
(base) NicuMarasoius-MacBook-Pro-3:kafka nicu$
nmarasoiu commented 4 years ago

Version 1.5.0 MacOs El Capitain

nmarasoiu commented 4 years ago

Ok, with docker it is more clear what is happening:

(base) NicuMarasoius-MacBook-Pro-3:kafka nicu$ docker run -it --network=host edenhill/kafkacat:1.5.0 -b 169.254.212.189 -t t
% Auto-selecting Consumer mode (use -P or -C to override)
% Reached end of topic t [0] at offset 0
nmarasoiu commented 4 years ago

Perhaps removing that warning (which is misleading to some) would be worth it? Does it really try to connect locally ?

nmarasoiu commented 4 years ago

Also, the topic t has 16 million messages according to control center, and i can see them on 169.254.212.189 control center in topic t

nmarasoiu commented 4 years ago

Running without network=host (I have docker in virtualbox):


% Auto-selecting Consumer mode (use -P or -C to override)
% ERROR: Local: Broker transport failure: localhost:9092/1: Connect to ipv4#127.0.0.1:9092 failed: Connection refused (after 0ms in state CONNECT)```
edenhill commented 4 years ago

The broker is advertising itself as localhost through advertisted.listeners. You can see this by kafkacat -b bootstrap -L

See this blog post for more info https://rmoff.net/2018/08/02/kafka-listeners-explained/