Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic load for librdkafka libraries not working in NetFramework projects with 2.6.0 #2328

Open
dmalanij opened this issue Oct 17, 2024 · 6 comments

Comments

@dmalanij
Copy link

dmalanij commented Oct 17, 2024

Description

When using the libraries in Net 4.8 project (in particular a WebAPI), as of 2.6.0 the initialization of the Confluent.Kafka.Impl.Librdkafka initialization fails with a DllNotFoundException and the message:

Failed to load the librdkafka native library.

How to reproduce

In a NetFramework project, reference to the latest version of the Confluent.Kafka package; as soon as the runtime reaches the Kafka initialization (ie: using the ProducerBuilder<,>) the exception is thrown even if the redist assemblies are in place (in particular in the bin\librdkafka as the librdkafka.redist package targets take care of).

Root cause Analysis

I believe that the problem is hapenning because 2.6.0 has not included the target for net462; therefore the initialization goes through the netstandard variation without the automatic path resolution that is present for the cases of net462.

Workaround

This can be avoided by simply including a call to Library.Load(path) where path contains the location for the librdkafka.dll (which in case can be ripped of inspired by the logic used by the implementation of the LoadNetFrameworkDelegates.

@UBSaxo
Copy link

UBSaxo commented Oct 31, 2024

We face same blocking issue. I cloned Confluent.Kafka and could easily reproduce it simply by changing the target framework of Confluent.Kafka.UnitTests test project to net48 and then loads of tests fail with the DllNotFoundException.

@anchitj
Copy link
Member

anchitj commented Nov 20, 2024

Can you try with 2.6.1? We've added back net462

@dmalanij
Copy link
Author

Can you try with 2.6.1? We've added back net462

I'll give it a try as soon as I can, right now we're in the final stage of our release cycle so the dependencies are fixed.
Cheers

@UBSaxo
Copy link

UBSaxo commented Nov 25, 2024

I have validated this by running your own unit tests against net48 and that works. With 2.6.0 that failed.

I would still love to see your automated tests extended to also cover NET Framework to avoid this mistake from repeating itself in future.

@samuelburnett
Copy link

I am still encountering this issue. I have a NET Framework 4.8 project that references 2.6.1 and receive the following error at runtime:
Error while loading librdkafka.dll or its dependencies from C:\PATH_TO_PROJECT\bin\Debug\librdkafka.dll.

No issue in my NET 6 project referencing 2.6.1.

@dmalanij
Copy link
Author

Can you try with 2.6.1? We've added back net462

Finally we were able to do the update and, same as @UBSaxo, the code is working fine now with 2.6.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants