问题
I have an issue about sending message to Kafka using port forwarding. We are using port forwarding for Kafka like this:
| Hostname | IP | Port | Port Forwarding |
|----------|---------------|------|-----------------------|
| kafka01 | 192.168.0.100 | 9092 | 106.107.118.119:30124 |
| kafka02 | 192.168.0.101 | 9092 | 106.107.118.119:30125 |
| kafka03 | 192.168.0.102 | 9092 | 106.107.118.119:30126 |
To connect to kafka broker from my localhost, I have to use VPN to connect to these addresses 192.168.0.X:9092
and it sent message to Kafka from my localhost (my laptop) successfully. But when deploying my application to real servers which has to use port forwarding to connect to Kafka brokers, it sent no message to kafka without any error display.
From real servers, it still can connect to kafka brokers (telnet 106.107.118.119 30124
successfully). I have no idea why. This is the producer config:
INFO | jvm 1 | 2017/07/29 16:34:36 | [2017-07-29 04:34:36] INFO -
ProducerConfig values:
INFO | jvm 1 | 2017/07/29 16:34:36 | compression.type = none
INFO | jvm 1 | 2017/07/29 16:34:36 | metric.reporters = []
INFO | jvm 1 | 2017/07/29 16:34:36 | metadata.max.age.ms = 300000
INFO | jvm 1 | 2017/07/29 16:34:36 | metadata.fetch.timeout.ms =
60000
INFO | jvm 1 | 2017/07/29 16:34:36 | acks = 1
INFO | jvm 1 | 2017/07/29 16:34:36 | batch.size = 16384
INFO | jvm 1 | 2017/07/29 16:34:36 | reconnect.backoff.ms = 10
INFO | jvm 1 | 2017/07/29 16:34:36 | bootstrap.servers =
[106.107.118.119:30124, 106.107.118.119:30125, 106.107.118.119:30126]
INFO | jvm 1 | 2017/07/29 16:34:36 | receive.buffer.bytes = 32768
INFO | jvm 1 | 2017/07/29 16:34:36 | retry.backoff.ms = 100
INFO | jvm 1 | 2017/07/29 16:34:36 | buffer.memory = 33554432
INFO | jvm 1 | 2017/07/29 16:34:36 | timeout.ms = 30000
INFO | jvm 1 | 2017/07/29 16:34:36 | key.serializer = class
org.apache.kafka.common.serialization.StringSerializer
INFO | jvm 1 | 2017/07/29 16:34:36 | retries = 0
INFO | jvm 1 | 2017/07/29 16:34:36 | max.request.size = 1048576
INFO | jvm 1 | 2017/07/29 16:34:36 | block.on.buffer.full = true
INFO | jvm 1 | 2017/07/29 16:34:36 | value.serializer = class
org.apache.kafka.common.serialization.StringSerializer
INFO | jvm 1 | 2017/07/29 16:34:36 | metrics.sample.window.ms = 30000
INFO | jvm 1 | 2017/07/29 16:34:36 | send.buffer.bytes = 131072
INFO | jvm 1 | 2017/07/29 16:34:36 |
max.in.flight.requests.per.connection = 5
INFO | jvm 1 | 2017/07/29 16:34:36 | metrics.num.samples = 2
INFO | jvm 1 | 2017/07/29 16:34:36 | linger.ms = 1
INFO | jvm 1 | 2017/07/29 16:34:36 | client.id =
INFO | jvm 1 | 2017/07/29 16:34:36 | - in logAll() at line 113 of
class org.apache.kafka.common.config.AbstractConfig
It does not show any error but when using simple Kafka consumer application, there is no message in kafka, while it has message when sending from my computer (bootstrap.servers=[192.168.0.100:9092, 192.168.0.101:9092, 192.168.0.102:9092]
). Any one knows about this issue?
来源:https://stackoverflow.com/questions/45386875/unable-to-send-kafka-message-through-port-forwarding