Search code examples
c#apache-kafkaazure-eventhub

Can't connect to EventHubs with Kafka Client


I have an event hubs instance with a “test” eventhub.

I can connect to this and publish messages with the native client "Azure.Messaging.EventHubs"

However when I try to connect with the Confluent.Kafka (v1.1.0) client I get

“Unknown error (after 21286ms in state CONNECT)” %3|1655301022.374|ERROR|rdkafka#producer-1| [thrd:sasl_plaintext://my-event-hub-namespace.servicebus.windows.net:9093/bootstra]: 1/1 brokers are down

I'm setting the producer config, and creating producer as below

var config = new ProducerConfig
{
    BootstrapServers = "my-eventhub-namespace.servicebus.windows.net:9093",
    SecurityProtocol = SecurityProtocol.SaslSsl,
    SaslMechanism = SaslMechanism.Plain,
    SaslUsername = "$ConnectionString",
    SaslPassword = "Endpoint=sb://my-eventhub-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=MySharedAccessKey==",
};

using (var producer = new ProducerBuilder<long, string>(config).SetKeySerializer(Serializers.Int64).SetValueSerializer(Serializers.Utf8).Build())
{

Any ideas as to where I'm going wrong?


Update :
When connecting with the native client it's connecting using WebSockets, so it's probably networking/firewall issue. Thanks for your time.


Solution

  • A couple of things to try

    • Firewall check for EH endpoint. Make sure the client can connect to my-eventhub-namespace.servicebus.windows.net:9093.
    • Try with a namespace-level connection string if you used entity-level SAS.