Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to resolve nodejs deprecation warning - RFC 6066 - seems to be coming from kafkajs #1407

Closed
adbdkb opened this issue Jul 1, 2022 · 1 comment · Fixed by #1425
Closed

Comments

@adbdkb
Copy link

adbdkb commented Jul 1, 2022

I am trying to create a sample nodejs app for kafkajs producer and consumer. When I start the app, I get the deprecation warning. So, I tried with --trace-deprecation flag and get this stack trace. How can I fix it? I tried using different versions of kafkajs, but still keep getting this error

(node:61452) [DEP0123] DeprecationWarning: Setting the TLS ServerName to an IP address is not permitted by RFC 6066. This will be ignored in a future version. at Object.connect (node:_tls_wrap:1670:15) at /BitBucketRepos/node-js/SimpleProducerConsumer/node_modules/kafkajs/src/network/socketFactory.js:12:13 at module.exports (/BitBucketRepos/node-js/SimpleProducerConsumer/node_modules/kafkajs/src/network/socket.js:24:18) at /BitBucketRepos/node-js/SimpleProducerConsumer/node_modules/kafkajs/src/network/connection.js:240:23 at new Promise (<anonymous>) at Connection.connect (/BitBucketRepos/node-js/SimpleProducerConsumer/node_modules/kafkajs/src/network/connection.js:167:12) at ConnectionPool.getConnection (/BitBucketRepos/node-js/SimpleProducerConsumer/node_modules/kafkajs/src/network/connectionPool.js:56:24) at Broker.connect (/BitBucketRepos/node-js/SimpleProducerConsumer/node_modules/kafkajs/src/broker/index.js:86:52) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /BitBucketRepos/node-js/SimpleProducerConsumer/node_modules/kafkajs/src/cluster/brokerPool.js:319:9

I have tried with using ksfkajs version 1.15.0, 1.16.0, 2.1.0 in package.json - but keep getting the same error.

My current NodeJs version is 18.0.0

How can I eliminate this warning?

@Nevon
Copy link
Collaborator

Nevon commented Jul 25, 2022

This can be worked around by setting ssl.servername to a hostname. If you don't set it, we default it to the broker host, which can be an IP. You can see an example of fixing this in our example clients:

const kafka = new Kafka({
logLevel: logLevel.INFO,
logCreator: PrettyConsoleLogger,
brokers: [`${host}:9094`, `${host}:9097`, `${host}:9100`],
clientId: 'test-admin-id',
ssl: {
servername: 'localhost',
rejectUnauthorized: false,
ca: [fs.readFileSync('./testHelpers/certs/cert-signed', 'utf-8')],
},
sasl: {
mechanism: 'plain',
username: 'test',
password: 'testtest',
},
})

#1425 will fix this by not defaulting the servername if the host is an IP address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants