Jroland / kafka-net

Native C# client for Kafka queue servers.
Apache License 2.0
482 stars 232 forks source link

Send producer problem when the service broker is offline #106

Open alfnunes opened 8 years ago

alfnunes commented 8 years ago

Hi, I'm facing a problem in case of the service broker is offline with the command

client.SendMessageAsync(topicName, new[] { new Message(message) }).Wait();

Are there anyay to see if the service broker is online before to send the message?

Thank you.

aries-zhang commented 7 years ago

I encountered the same problem. It seems the following timeout settings in KafkaOptions do not work.

var options = new KafkaOptions(uris) { MaximumReconnectionTimeout = TimeSpan.FromSeconds(2.5), ResponseTimeoutMs = TimeSpan.FromSeconds(15) };

If the broker is offline, the following line of code in line 107 KafkaConnection.cs hangs forever.

await _client.WriteAsync(request.Encode())

There should be a connection timeout option and if the broker is not accessible, exception should be thrown after waiting for a configured amount of time.