Raj Jagani
Raj Jagani

Reputation: 758

Kafka : Broker Transport Failure while using "SASL_PLAINTEXT" OR "PLAINTEXT" protocol

I am trying to connect the confluent Kafka broker using "SASL_PLAINTEXT" or "PLAINTEXT" but I am getting this error broker transport failure. However, it's working fine with the "SASL_SSL" protocol but not working with any other security protocol.

Here is my code.

const consumer = new Kafka.KafkaConsumer({
    'group.id':'gsuite_consumer',
    'metadata.broker.list': *******,
    'sasl.mechanisms': 'PLAIN',
    'sasl.username': *********,
    'sasl.password': ******,
    'security.protocol': 'PLAINTEXT'
}, {});

// Connect the consumer.
consumer.connect({timeout: "1000ms"}, (err) => {
    if (err) {
        console.log(`Error connecting to Kafka broker: ${err}`);
        process.exit(-1);
    }

    console.log("Connected to Kafka broker");
});

Any idea what's am I doing wrong? here to connect with the broker. I have also deployed this code on Heroku server as well and it's not working

Upvotes: 1

Views: 9117

Answers (1)

Mickael Maison
Mickael Maison

Reputation: 26885

The security protocol determine how the connection from the clients to the brokers is established. Each (PLAINTEXT, SASL_PLAINTEXT and SASL_SSL) work differently and only 1 of them is available on a port.

For example, if your brokers listen on 9093 with SASL_SSL, you need to use this exact protocol to connect on this port. Trying the other security protocols is expected to fail.

Take a look at the advertised.listeners configuration of your brokers to identify which port/protocol combinations they expose.

Upvotes: 3

Related Questions