Closed PrabhanjanDesai closed 9 months ago
@PrabhanjanDesai
Both the Writer and Reader objects have a connectLogger
boolean property you can set to see the internal logs of the Kafka library used in this extension, which is kafka-go. Consider setting that property and observing what happens. Also, if the connection timeouts happen intermittently, and not constantly, it might mean that your Kafka instance might not have enough resources to handle that many connections.
Thanks @mostafa . Issue doesn't seem to be with resources here, issue mainly occurs while we are establishing connection and not while initializing reader/writer.
@PrabhanjanDesai
I faced this issue as well, but since it's intermittent, it makes it very hard to reproduce and debug. I'd be happy to know how I can reproduce this.
@mostafa Unfortunately this issue occurs in only few clusters, cant provide anything that can help you reproduce. I would like to know two things -
Any update @mostafa on my latest questions ?
Hi @mostafa - Could you please provide your inputs?
@PrabhanjanDesai
connectLogger
in xk6-kafka code. The only possible way is to add heavy logging/printing to the code I referenced in item 1 and then build a custom version of k6 with xk6-kafka using xk6.As I also mentioned above, this is hard to reproduce.
Hey,
I suppose your question is answered, I'll close this issue. If you have further questions related to the same issue, please re-open this, otherwise open a new one.
hi @mostafa i get the error in ERRO[0000] TypeError: Value is not an object: undefined at file:///C:/kafka/k6-kafka/kafka.js:8:24(39) hint="script exception" after run the code
import { check } from 'k6';
import { writer, produce, reader, createTopic } from 'k6/x/kafka';
const bootstrapServers = ['localhost:9092'];
const kafkaTopic = 'xk6_kafka_json_topic';
// Initialize Kafka producer and consumer
const producer = writer(bootstrapServers, kafkaTopic);
const consumer = reader(bootstrapServers, kafkaTopic);
// Create Kafka topic
createTopic(bootstrapServers[0], kafkaTopic);
// Function to generate random integer
function getRandomInt(max = 1000) {
return Math.floor(Math.random() * max + 1);
}
// Main function for load testing
export default function () {
// Generate messages
const messages = [
{
key: JSON.stringify({
correlationId: 'test-id-sql-' + getRandomInt(),
}),
value: JSON.stringify({
title: 'Load Testing SQL Databases with k6',
url: 'https://k6.io/blog/load-testing-sql-databases-with-k6/',
locale: 'en',
}),
},
{
key: JSON.stringify({
correlationId: 'test-id-redis-' + getRandomInt(),
}),
value: JSON.stringify({
title: 'Benchmarking Redis with k6',
url: 'https://k6.io/blog/benchmarking-redis-with-k6/',
locale: 'en',
}),
},
];
// Produce messages
const error = produce(producer, messages);
check(error, {
'messages sent successfully': (err) => err === null,
});
}
// Teardown function to close producer and consumer connections
export function teardown(data) {
producer.close();
consumer.close();
}
Hey @Madhankumar11,
You are using a very old syntax to create topics. Consider updating your code according to this example.
Hi Team, I am facing this error during execution of my test case related to Strimzi Kafka. Basically the test case tries to produce the data on a topic.
The above logs are observed in my producer test cases. I don't see any errors in Strimzi Kafka pods during this time interval. Also this is intermittently happening. Any idea ?. As this is connecting on 9092 non-tls port/internal port and intermittently failing in same cluster, Need some inputs on debugging the same.
Kafka broker service -
Kafka custom resource -
I am using following in K6 tests