Unable to connect to Azure Event Hub using the Confluent .Net client

Craig Wheeler 1 Reputation point
2020-12-16T21:41:14.733+00:00

I am trying to use the Confluent .Net client (1.5.2) to connect to an Azure Event Hub but I keep getting an SSL handshake failed error.

My Confluent ProducerConfig looks like this:

var config = new ProducerConfig
{
    BootstrapServers = "ehNamespace.servicebus.windows.net:9093",
    SecurityProtocol = SecurityProtocol.SaslSsl,
    SaslMechanism = SaslMechanism.Plain,
    SaslUsername = "$ConnectionString",
    SaslPassword = "Endpoint=sb://ehNamespace.servicebus.windows.net/;SharedAccessKeyName=accessKeyName;SharedAccessKey=accessKey",
    SslCaLocation = "cacert.pem",
    Debug = "security,broker,protocol"
};

When I build the ProducerClient, it fails to connect with an SSL handshake failure:

%7|1607458909.957|SASL|rdkafka#producer-1| [thrd:app]: Selected provider PLAIN (builtin) for SASL mechanism PLAIN
%7|1607458909.958|OPENSSL|rdkafka#producer-1| [thrd:app]: librdkafka built with OpenSSL version 0x1000211f
%7|1607458910.231|SSL|rdkafka#producer-1| [thrd:app]: Loading CA certificate(s) from file cacert.pem
%7|1607458910.241|BRKMAIN|rdkafka#producer-1| [thrd::0/internal]: :0/internal: Enter main broker thread
%7|1607458910.241|BROKER|rdkafka#producer-1| [thrd:app]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: Added new broker with NodeId -1
%7|1607458910.242|CONNECT|rdkafka#producer-1| [thrd:app]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: Selected for cluster connection: bootstrap servers added (broker has 0 connection attempt(s))
%7|1607458910.242|BRKMAIN|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: Enter main broker thread
%7|1607458910.242|INIT|rdkafka#producer-1| [thrd:app]: librdkafka v1.5.2 (0x10502ff) rdkafka#producer-1 initialized (builtin.features gzip,snappy,ssl,sasl,regex,lz4,sasl_gssapi,sasl_plain,sasl_scram,plugins,zstd,sasl_oauthbearer, SSL ZLIB SNAPPY SASL_SCRAM PLUGINS HDRHISTOGRAM, debug 0x282)
%7|1607458910.242|CONNECT|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: Received CONNECT op
%7|1607458910.243|STATE|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: Broker changed state INIT -> TRY_CONNECT
%7|1607458910.243|CONNECT|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: broker in state TRY_CONNECT connecting
%7|1607458910.243|STATE|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: Broker changed state TRY_CONNECT -> CONNECT
%7|1607458910.273|CONNECT|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: Connecting to ipv4#40.71.10.149:9093 (sasl_ssl) with socket 1168
%7|1607458910.297|CONNECT|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: Connected to ipv4#40.71.10.149:9093
%7|1607458910.327|FAIL|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: SSL handshake failed: SSL transport error: Unknown error (after 84ms in state CONNECT) (_SSL)
%3|1607458910.327|FAIL|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: SSL handshake failed: SSL transport error: Unknown error (after 84ms in state CONNECT)
%7|1607458910.329|STATE|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap: Broker changed state CONNECT -> DOWN
%3|1607458910.330|ERROR|rdkafka#producer-1| [thrd:sasl_ssl://ehNamespace.servicebus.windows.net:9093/bootstrap]: 1/1 brokers are down

I have tried this with two different Event Hubs with no luck. Can someone help me understand why this is failing and what I can do to get it working?

Thanks!

Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
654 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.