confluentinc / confluent-kafka-dotnet

Confluent's Apache Kafka .NET client
https://github.com/confluentinc/confluent-kafka-dotnet/wiki
Apache License 2.0
80 stars 866 forks source link

Unhandled Confluent.Kafka.KafkaException when attempting to produce with ACLs in place #248

Closed htims1989 closed 6 years ago

htims1989 commented 7 years ago

Description

Attempting to produce with ACLs in place that deny access causes producer.ProduceAsync to throw:

An unhandled exception of type 'Confluent.Kafka.KafkaException' occurred in Confluent.Kafka.dll Additional information: Local: Unknown topic

consumer.Poll correctly returns an error via the consumer.OnError event:

Error consuming from topic/partition/offset /0/0: Broker: Group authorization failed

How to reproduce

Enable client authentication on the broker and set up an ACL using the certificates Subject to deny access. Attempt to produce using producer.ProduceAsync.

Checklist

Please provide the following information:

treziac commented 7 years ago

https://github.com/confluentinc/confluent-kafka-dotnet/wiki/Producing-messages#important-notes

At current time, ProduceAsync may throw exception in some case (message too big for example). This may change in a future release (no throw but returns a message with Error instead)

To be more clear, on first send, ProduceAsync will success but DeliveryHandler will contain an error (unknown topic) Next call will directly return by throwing without trying to send the data because the error is considered permanent (need manual intervention) It will try again if metadata which are called frequently show the topic has been created

You have to call ProduceAsync in a Try/Catch + check the message.Error to know if an error occured. This is tracked in #203

mhowlett commented 6 years ago

tracking in #203