When kafka2.11-0.9.0.0 achieve Producer send a message can not be sent, the error message: org.apache.kafka.common.errors.TimeoutException: Batch Expired

In the beginning of this pseudo-cluster machine built kafka, local producer announced the success of the client to broker. Then set up on the server (virtual machine) the kafka cluster, the cluster is connected in the machine, producer but can not post messages to the broker (strange nor throwing error). Initially suspected iptables not open, then open port, the result is not enough (they began to suspect that the problem is the code, version of the problem and so on, and shift for a long time). Later print the return information, the report found abnormal org.apache.kafka.common.errors.TimeoutException: Batch Expired

Reference to some solutions online, eventually locking modify the following configuration information.

 

# The address the socket server listens on. It will get the value returned from 
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = security_protocol://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://:9092
 # Hostname and port the broker will advertise to producers and consumers. If not set, 
 # it uses the value for "listeners" if configured. Otherwise, it will use the value
 # returned from java.net.InetAddress.getCanonicalHostName().
 #advertised.listeners=PLAINTEXT://your.host.name:9092

 

Above that is advertised.listeners is broker to the producer and the consumer connection, if not set, use listeners, but if host_name is not set, then it using java.net.InetAddress.getCanonicalHostName () method returns the host name.

 

Modification method:

Modified as follows server.properties

Before the amendment: 

in the Listeners = PLAINTEXT: //: 9092 

modified 

in the Listeners = PLAINTEXT: //192.168.x.100: 9092 
advertised.listeners = PLAINTEXT: //10.10.xx.252: 9092

192.168.x.100 which is a virtual machine within the network address

10.10.xx.252 is outside the network address of the server virtual machine installed map

If a virtual machine is also need to configure port mapping, and the push host's virtual machines and the host, the protocol stack.

After the modification restart kafka service.

 

Guess you like

Origin www.cnblogs.com/copykakaxi/p/12524293.html