Bharat
Bharat

Reputation: 1082

Cannot connect to remote kafka broker even after configuring advertised listeners

I have a vm created in GCP and I setup kafka in it. I had changed the advertised listeners to the external public ip of the vm.

enter image description here

But when ever I try to connect from the local laptop I keep getting this error.

enter image description here

I checked the connectivity to machine from ping and I am getting response

PING 34.69.37.118 (34.69.37.118): 56 data bytes
64 bytes from 34.69.37.118: icmp_seq=0 ttl=54 time=266.223 ms
64 bytes from 34.69.37.118: icmp_seq=1 ttl=54 time=290.133 ms
64 bytes from 34.69.37.118: icmp_seq=2 ttl=54 time=264.678 ms
64 bytes from 34.69.37.118: icmp_seq=3 ttl=54 time=263.067 ms
^C
--- 34.69.37.118 ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 263.067/271.025/290.133/11.088 ms

Upvotes: 1

Views: 644

Answers (1)

Giorgos Myrianthous
Giorgos Myrianthous

Reputation: 39790

If your client (Kafka Producer) it is outside of the VM, you need to expose the following:

listeners=INTERNAL://0.0.0.0:19092,EXTERNAL://0.0.0.0:9092
listener.security.protocol.map=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
advertised.listeners=INTERNAL://vm-address:19092,EXTERNAL://host-address:9092
inter.broker.listener.name=INTERNAL

Now your producer should use 19092

Upvotes: 3

Related Questions