Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

kafka producer error I/O

Solved Go to solution

kafka producer error I/O

Super 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

Accepted Solutions
Highlighted

Re: kafka producer error I/O

Super Collaborator

Hi:

I resolved the problem opening the port 6667.

Regars

3 REPLIES 3

Re: kafka producer error I/O

New Contributor

what is the producer and broker versions?

Highlighted

Re: kafka producer error I/O

Super Collaborator

Hi:

I resolved the problem opening the port 6667.

Regars

Re: kafka producer error I/O

Super 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)

:)