Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

kafka producer error I/O

avatar
Master Collaborator

Hi:

I have executing this code

public class productor {
    
      public static void main(String[] args) {
     Properties properties = new Properties();
        properties.put("metadata.broker.list", "xxxxxx:6667");
        properties.put("bootstrap.servers", "xxxxxx:6667");
        properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");// key serializer
        properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); //value serializer
        properties.put("acks", "1"); //message durability -- 1 mean ack after writing to leader is success. value of "all" means ack after replication.
        properties.put("security.protocol", "PLAINTEXT"); // Security protocol to use for communication.
        properties.put("batch.size", "16384");// maximum size of message 


        KafkaProducer<String,String> producer = new KafkaProducer<String, String>(properties);
        
          try {
            for (int i = 0; i < 10; i++) {
                // send lots of messages
                producer.send(new ProducerRecord<String, String>("RSI","sancho"+i));
                System.out.println("RSI"+ " sancho"+i);
            }


        } catch (Throwable throwable) {
            System.out.println(throwable.getMessage());
        } finally {
            producer.close();
        }
     }

and receiving this error, what is happening??

run:
[2016-08-29 15:05:09,552] ERROR Uncaught error in kafka producer I/O thread:  (org.apache.kafka.clients.producer.internals.Sender:136)
org.apache.kafka.common.protocol.types.SchemaException: Error reading field 'brokers': Error reading field 'host': Error reading string of length 27758, only 169 bytes available
	at org.apache.kafka.common.protocol.types.Schema.read(Schema.java:73)
	at org.apache.kafka.clients.NetworkClient.parseResponse(NetworkClient.java:380)
	at org.apache.kafka.clients.NetworkClient.handleCompletedReceives(NetworkClient.java:449)
	at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:269)
	at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:229)
	at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:134)
	at java.lang.Thread.run(Thread.java:745)


1 ACCEPTED SOLUTION

avatar
Master Collaborator

Hi:

I resolved the problem opening the port 6667.

Regars

View solution in original post

3 REPLIES 3

avatar
New Contributor

what is the producer and broker versions?

avatar
Master Collaborator

Hi:

I resolved the problem opening the port 6667.

Regars

avatar
Master Collaborator

thanks, so remember when one client(producer and consumer need to conect to a remote cluster, we need to open the ports from the servers, and also use the same version of kafka client and server)

🙂