examples
examples copied to clipboard
Timeout connecting to Confluent Kafka: -185 error
Good day,
I keep getting a timeout when trying to connect to Confluent Kafka using the credentials supplied by Confluent and using the following structure in the https://github.com/confluentinc/examples/tree/master/clients/cloud/nodejs project:
Example from CLI and client configuration:
bootstrap.servers=<SERVER_URL> sasl.username=<CLUSTER_API_KEY> sasl.password=<CLUSTER_API_SECRET>
Please can you have a look at this issue
I have the same issue trying the node example:
➜ node producer.js -f $HOME/.confluent/librdkafka.config -t test-topic
Something went wrong:
Error: Local: Timed out
➜ cat $HOME/.confluent/librdkafka.config
bootstrap.servers=<BROKER>:9092
sasl.username=<API KEY>
sasl.password=<API SECRET>
security.protocol=SASL_SSL
sasl.mechanisms=PLAIN
{ Error: Local: Timed out
at Function.createLibrdkafkaError [as create] (/home/myuser/code/examples/clients/cloud/nodejs/node_modules/node-rdkafka/lib/error.js:261:10)
at /home/myuser/code/examples/clients/cloud/nodejs/node_modules/node-rdkafka/lib/admin.js:132:28
message: 'Local: Timed out',
code: -185,
errno: -185,
origin: 'kafka' }
I've just come across the same issue, setting the following config item, fixed it for me
api.version.request=false
so it should be:
const producer = new Kafka.Producer({
'bootstrap.servers': config['bootstrap.servers'],
'sasl.username': config['sasl.username'],
'sasl.password': config['sasl.password'],
'security.protocol': config['security.protocol'],
'sasl.mechanisms': config['sasl.mechanisms'],
'api.version.request': false,
'dr_msg_cb': true
});
Thanks - another thing i had to do was:
- Install opensssh
brew install openssh
- put literal api credentials into nodejs.config ie
# Required connection configs for Kafka producer, consumer, and admin
bootstrap.servers=......confluent.cloud:9092
security.protocol=SASL_SSL
sasl.mechanisms=PLAIN
sasl.username=abc123
sasl.password=abc123
# Best practice for higher availability in librdkafka clients prior to 1.7
session.timeout.ms=45000
- Ensure the topic requested exists (the example assumes
test1
exists... - Edit adminClient in
producer.js
to include api.version.request as suggested above:
...
const adminClient = Kafka.AdminClient.create({
"bootstrap.servers": config["bootstrap.servers"],
"sasl.username": config["sasl.username"],
"sasl.password": config["sasl.password"],
"security.protocol": config["security.protocol"],
"sasl.mechanisms": config["sasl.mechanisms"],
"api.version.request": false,
});
...