Unhandled Exception: Confluent.Kafka.KafkaException: Disconnected after ms in state up
See original GitHub issueDescription
Sometimes I got error:
Unhandled Exception: Confluent.Kafka.KafkaException: 10.244.3.12:9092/1: Disconnected (after 1438771ms in state UP) at Common.EventBus.KafkaProducer.<.ctor>b__4_1(IProducer
2 _, Error errorHandler) at Confluent.Kafka.Impl.NativeMethods.NativeMethods_Debian9.rd_kafka_poll(IntPtr rk, IntPtr timeout_ms) at Confluent.Kafka.Producer
2.<>c__DisplayClass24_0.<StartPollTask>b__0() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
ctor of my KafkaProducer class
public KafkaProducer(EventBusOptions options, ILogger<KafkaProducer> logger)
{
_options = options ?? throw new ArgumentException(nameof(options));
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
var producerConfig = new ProducerConfig
{
BootstrapServers = options.ConnectionString,
EnableIdempotence = true,
CompressionType = CompressionType.Snappy
};
_producer = new ProducerBuilder<string, string>(producerConfig)
.SetLogHandler((_, logMessage) => _logger.LogInformation(logMessage.Message))
.SetErrorHandler((_, errorHandler) =>
{
_logger.LogError(errorHandler.Reason);
throw new KafkaException(errorHandler);
})
.Build();
}
How to reproduce
After sending message like
public async Task Send(IntegrationEvent eventData)
{
var jsonMessage = JsonConvert.SerializeObject(eventData, new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
var message = new Message<string, string>
{
Value = jsonMessage,
Headers = new Headers
{
{"eventType", Encoding.UTF8.GetBytes(eventData.EventType.ToLowerInvariant()) }
}
};
_producer.Produce(topicName, message, report =>
{
if (report.Error.IsError)
{
_logger.LogError(report.Error.Reason);
}
else
{
_logger.LogInformation("Event message '{EventType}' with Id '{MessageId}' sent to topic '{TopicName}'", eventData.EventType, eventData.Id.ToString(), report.TopicPartitionOffset);
}
});
}
Log
Mar 4, 2020 @ 12:07:14.214 Event message ‘“con_integration”’ with Id ‘“c846365a-dcc7-4a48-b6f3-5116aeb72b96”’ sent to topic ‘“dev_con_integration [[11]] @164”’ Mar 4, 2020 @ 12:17:14.439 10.244.2.165:9092/0: Disconnected (after 992313ms in state UP) – –
Checklist
- Confluent.Kafka nuget version 1.3.0
- Apache Kafka image: confluentinc/cp-kafka:5.0.1
- Operating system: Linux
- Critical issue.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Enum ErrorCode | Confluent.Kafka
Producer attempted a transactional operation in an invalid state. InvalidUpdateVersion. Invalid update version. KafkaStorageError. Disk error when trying to ...
Read more >c# - Confluent-kafka-dotnet - Consumers hangs when ...
I'm using this kafka client - https://github.com/confluentinc/confluent-kafka-dotnet Consumers hangs when committing offset after few seconds ...
Read more >Timeout Error When Using kafka-console-consumer an... - ...
When I bring up kafka-console-consumer, a few minor log messages come up, and then it sits ... TimeoutException: Failed to update metadata after...
Read more >Consumer disconnected after X ms in state UP
I first thought it is connection issue but the producer is connecting to same Kafka and is able to produce properly. I don't...
Read more >What does the heartbeat thread do in Kafka Consumer?
Obviously the easiest solution is to send some status updates via network saying that we're still alive and evict each other based on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
that error is not fatal.
if you do get a fatal error, every call to every method will also give you an exception. if you don’t it’s fine to keep using the producer. the name ‘error’ here is unfortunate and historical reasons - it’s confusing, yes.