Kafka in Unity not working. Seems to have broken assemblies or conflicting with Unity's. How to fix?
See original GitHub issueDescription
I want to integrate Kafka in Unity for a Windows build (I am on Windows).
However I either get errors such as this one:
Error: Could not load signature of Confluent.Kafka.IAsyncDeserializer`1[T]:DeserializeAsync due to: Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. assembly:System.Memory, Version=4.0.1.0,
Or if I install the System.Memory version that comes with the Kafka NuGet dependency, I get errors all over the place of Unity’s own method/class references no longer being found.
How to reproduce
I have tried installing the latest release (1.3.0) from nuget (using the UnityPackage ‘NuGetForUnity’). This did not seem to work and had the second type of error result described above.
I have then tried to build the source and copy the relevant DLL’s manually, and tried the same with the nuget release version. This gives the first type of error result described above.
Can anyone please help me with installing Kafka for Unity?
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (2 by maintainers)
Top GitHub Comments
@ztolley I needed to do the same thing and recently figured it out. You may be missing the
librdkafka.dll
file for your system. For reference, here are the steps I used to get Kafka working in my project:.unitypackage
from their GitHub.BootstrapServers = "localhost:9092"
to reflect your server andc.Subscribe("networktopic_data");
to the name of the topic you wish to subscribe to.StreamMessage
withstring
for now. ReplaceStreamMessage message = ParseStreamMessage.Decode(cr.Value);
withstring message = Encoding.UTF8.GetString(cr.Value);
. ReplaceProcessPBMessages.Process(message);
withDebug.Log(message);
. Once you can play the scene and confirm you are receiving messages in the Console, you can try using NewtonsoftJsonConvert
or something similar to work for your use case.Hope that helps!
reopening, it would be good for us to test this and make this work ootb.