question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I'm getting `ETIMEDOUT` and `authentication failed` on the 2nd topic only. How can I better troubleshoot this?

See original GitHub issue

I’m having an issue subscribing a consumer to multiple topics. Usually the first topic or 2 will succeed nearly instantly, then it hits a wall. It will hang for several minutes then output 3 error messages. If I continue waiting it will throw the same 3 error messages.

I’m having a hard time figuring out if this is an issue on my end, kafkajs, or my company’s Kafka instances. I’m leaning towards the client side of things since other teams here consume happily with Java connectors.

NOTE: I redacted various things in code and the logs

Code:

(async () => {
	const topics = ['topic-a', 'topic-b', 'topic-c'];

	const kafka = new Kafka({
		clientId: 'some-client-id',
		brokers: ['some-broker.redacted.com:9093'],
		sasl: {/* REDACTED */},
	});

	const consumer = kafka.consumer({ groupId: 'some-group-id' });

	for (let topic of topics) {
		console.log(`Sub to ${topic}...`);
		await consumer.subscribe({ topic }); // hangs for several minutes on the second or 3rd topic
		console.log('...done');
	}

	// ... code for consumer.run below. It never makes it this far.
})();

Most of the time I get output like this:

Sub to topic-a...
...done
Sub to topic-b...
(Hangs here for several minutes...)
{"level":"ERROR","timestamp":"2019-10-14T21:25:12.210Z","logger":"kafkajs","message":"[Connection] Connection error: read ETIMEDOUT","broker":"some-broker-a.redacted.com:9093","clientId":"some-client-id","stack":"Error: read ETIMEDOUT\n    at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27)"}
{"level":"ERROR","timestamp":"2019-10-14T21:25:12.212Z","logger":"kafkajs","message":"[SCRAM512Authenticator] SASL SCRAM SHA512 authentication failed: Connection error: read ETIMEDOUT","broker":"some-broker-a.redacted.com:9093"}
{"level":"ERROR","timestamp":"2019-10-14T21:25:12.212Z","logger":"kafkajs","message":"[BrokerPool] KafkaJSSASLAuthenticationError: SASL SCRAM SHA512 authentication failed: Connection error: read ETIMEDOUT","retryCount":0,"retryTime":294,"stack":"KafkaJSSASLAuthenticationError: SASL SCRAM SHA512 authentication failed: Connection error: read ETIMEDOUT\n    at SCRAM512Authenticator.authenticate (/path-to-project/node_modules/kafkajs/src/broker/saslAuthenticator/scram.js:157:21)\n    at process._tickCallback (internal/process/next_tick.js:68:7)"}

If I let it sit it will eventually throw the same 3 error messages.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
tulioscommented, Oct 17, 2019

consumer.subscribe will first refresh the current metadata if it is necessary, then it will randomly select a broker it knows, and it will request metadata for the specific topic you provided.

I noticed that you are getting the error SASL SCRAM SHA512 authentication failed, and your example is using port 9093, which usually only accepts SSL connections but no SASL. If you provide SASL configurations it the client will attempt to authenticate, but since the port doesn’t accept SASL, it might never reply, leading to a timeout.

0reactions
JaapRoodcommented, Oct 18, 2019

If this was the problem, wouldn’t it NEVER work? I see now that I wasn’t super clear on this, but it usually fails but does occasionally work.

A broker known to the client is randomly selected to request the metadata for the specific topic. If that broker also doesn’t hold the partitions you’re trying to access, it’s conceivable how that particular broker just isn’t used.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solve “Connect ETIMEDOUT” error - Ledger Support
The error can happen for the following reasons: You're trying to access My Ledger or to add a new account in Ledger Live....
Read more >
Getting ETIMEOUT error when attempting to connect - MongoDB
If both connects, then first try these two directly to connect to this server of the cluster. and then try the same but...
Read more >
Resolving User Login Authentication Failure Issues
This section helps you resolve some of the most common user login authentication failure issues encountered while using Oracle Business Intelligence ...
Read more >
Connect ETIMEDOUT error ? — Xano Community
Hi everybody, I have a recurring problem and I do not understand where it comes from... After 1200/1300 different API calls, I often...
Read more >
Nodemailer connection timeout error - Stack Overflow
This may be firewall problem. I faced similar problem in Ubuntu (Digital Ocean server). Tried to fix the issue for 3 days, tried...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found