Getting the following exception when building a consumer using 1.0.0-beta3:
Unhandled Exception: System.DllNotFoundException: Failed to load the librdkafka native library.
at Confluent.Kafka.Impl.Librdkafka.Initialize(String userSpecifiedPath)
at Confluent.Kafka.Consumer2..ctor(ConsumerBuilder2 builder)
at Confluent.Kafka.ConsumerBuilder2.Build()
at Confluent.Kafka.Examples.ConsumerExample.Program.Run_Consume(String brokerList, List1 topics, CancellationToken cancellationToken) in /src/confluent-kafka-dotnet/examples/Consumer/Program.cs:line 60
at Confluent.Kafka.Examples.ConsumerExample.Program.Main(String[] args) in /src/confluent-kafka-dotnet/examples/Consumer/Program.cs:line 192
Abort trap: 6
Run the Consumer example console app using 1.0.0-beta3.
(https://github.com/confluentinc/confluent-kafka-dotnet/tree/master/examples/Consumer)
If I run the Consumer example app with from the 1.0.0-beta2 release, it works without error.
Please provide the following information:
thanks for reporting. this is because the zstd dependency of librdkafka 1.0-RC7 is not available on macos by default. for now you could try installing that (i have not, don't know what the process is, but guess it's not difficult), or compiling librdkafka / installing from source (this is easy). if you do the latter, the librdkafka version you have on your system will be automatically used when the version in the nuget package fails to load.
this issue will be fixed before the 1.0 final release.
The workaround for now is brew install zstd on osx
We also had to upgrade OpenSSL on osx by brew upgrade openssl to resolve the issue
I am also seeing this with 0.11.6 on linux. I have installed zstd as suggested in the workaround, this didn't fix the issue.
$ dotnet run -p src/Kafka.Consumer
Unhandled Exception: System.DllNotFoundException: Failed to load the librdkafka native library.
at Confluent.Kafka.Impl.LibRdKafka.Initialize(String userSpecifiedPath)
at Confluent.Kafka.Consumer..ctor(IEnumerable`1 config)
at Confluent.Kafka.Consumer`2..ctor(IEnumerable`1 config, IDeserializer`1 keyDeserializer, IDeserializer`1 valueDeserializer)
at Kafka.Consumer.Program.Main(String[] args) in /home/ritasker/projects/Kafka/src/Kafka.Consumer/Program.cs:line 23
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.102
Commit: 96ff75a873
Runtime Environment:
OS Name: manjaro
OS Version:
OS Platform: Linux
RID: arch-x64
Base Path: /opt/dotnet/sdk/2.2.102/
Host (useful for support):
Version: 2.2.1
Commit: 878dd11e62
.NET Core SDKs installed:
2.2.102 [/opt/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.NETCore.App 2.2.1 [/opt/dotnet/shared/Microsoft.NETCore.App]
zstd is new in 1.0 - doesn't apply to 0.11.6. your problem will be that another required dependency of librdkafka is not on your system. you can use ldd for more info. Something like: ldd ~/.nuget/packages/librdkafka.redist/0.11.6/runtimes/linux-x64/native/librdkafka.so. This info might also help: https://github.com/edenhill/librdkafka/wiki/Dependencies
Looks like I am missing libsasl2.so.2.
$ ldd ~/.nuget/packages/librdkafka.redist/0.11.6/runtimes/linux-x64/native/librdkafka.so
linux-vdso.so.1 (0x00007ffe406e7000)
libsasl2.so.2 => not found
libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007f265f408000)
libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007f265f19b000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f265f016000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f265edff000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f265edfa000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f265edd7000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007f265edcd000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f265ec09000)
/usr/lib64/ld-linux-x86-64.so.2 (0x00007f265f7ab000)
if you install that, it should work.
@ritasker
Looks like you're on an Arch Linux derivative. With libsasl installed, the library is actually libsasl2.so.3 while the prebuilt librdkafka.so is attempting to link to libsasl2.so.2.
I manually built librdkafka myself so it would link against the right libsasl, and then replaced ~/.nuget/packages/librdkafka.redist/1.0.0-rc7/runtimes/linux-x64/native/librdkafka.so with the version I manually built.
That should fix it.
Thanks @vertexmachina I will give it ago when I am back off holiday.
@brightermatter You are right! This library need openssl. Once I install openssl to my macOS, issue was fixed! Thank you so much!
just wanted to note in this thread that the latest librdkafka.redist package (1.0-RC8) will work out of the box with many more (the majority of all) linux distros. it contains 4 builds for linux, which it will attempt to load in the following order:
Hello,
I am running 1.2.0 on Unity 3D
I have a basic consumer example, and am getting:
DllNotFoundException: kernel32
Confluent.Kafka.Impl.Librdkafka.Initialize (System.String userSpecifiedPath) (at <8f0e45c156f948c58d05e6d1b69d0ee8>:0)
Confluent.Kafka.Consumer`2[TKey,TValue]..ctor (Confluent.Kafka.ConsumerBuilder`2[TKey,TValue] builder) (at <8f0e45c156f948c58d05e6d1b69d0ee8>:0)
I have brew installed openssl and zstd. Are there any other suggestions?
Thank you for any help or pointing me to a better place to ask this question.
Use this in dockerfile , it was installed and worked fine.
FROM mcr.microsoft.com/dotnet/core/runtime:3.0 AS runtime
RUN apt-get update -y
RUN apt-get install -y librdkafka-dev
If you have any errors i will share my full dockerfile
@ratri-git I added those lines but I still get "Failed to load the librdkafka native library."
Do you expect resulting files for librdkafka-dev to exist somewhere after running that apt-get?
Yes, I'd like to see the full dockerfile.
Following this just leads me to this issue -> https://github.com/confluentinc/confluent-kafka-dotnet/issues/1596
Most helpful comment
Use this in dockerfile , it was installed and worked fine.
If you have any errors i will share my full dockerfile