Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems using RabbitMQ on Android device using Mono/Unity3D

I'm working on a game using Unity3D, and trying to deploy it to Android and iOS devices. I'm using RabbitMQ/AMQP to communicate with a server for online play.

When I run my game in the Unity editor and on iOS devices, all of the networking code works fine. However, when I deploy to Android devices there seem to be issues with some of the .NET libraries agreeing with RabbitMQ.

When the game is first run (and the connection to the server is being established), I get the following error in my logcat:

E/Unity ( 5378): Connection exception: None of the specified endpoints were reachable
E/Unity ( 5378): Endpoints attempted:
E/Unity ( 5378): ------------------------------------------------
E/Unity ( 5378): endpoint=amqp-0-9://robot.lvl6.com:5672, attempts=1
E/Unity ( 5378): System.EntryPointNotFoundException: getifaddrs
E/Unity ( 5378): at (wrapper managed-to-native) System.Net.NetworkInformation.LinuxNetworkInterface:getifaddrs (intptr&)
E/Unity ( 5378): at System.Net.NetworkInformation.LinuxNetworkInterface.ImplGetAllNetworkInterfaces () [0x00000] in :0
E/Unity ( 5378): at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces () [0x00000] in :0
E/Unity ( 5378): ================================================
E/Unity ( 5378): Stack trace:
E/Unity ( 5378): at RabbitMQ.Client.ConnectionFactory.CreateConnection (Int32 maxRedirects) [0x00000] in :0
E/Unity ( 5378): at RabbitMQ.Client.ConnectionFactory.CreateConnection () [0x00000] in :0
E/Unity ( 5378): at UMQNetworkManager.Start () [0x0009a]

Now, I've been able to find this post regarding problems with GetAllNetworkInterfaces(), however I'm having difficulty figuring out how to move forward from here.

Is there some way to easily work around getifaddrs not being accessible on Android through Mono? Otherwise, it seems like my choices at this point are to either (A) Use a different AMQP library for the Android version of my client, (B) modify the source of RabbitMQ and recompile it in a way that would allow me to get it to work without needing getifaddrs, or (C) include the .jar for the Java version of RabbitMQ, and use Unity's AndroidJavaObject class to access the RabbitMQ framework through JNI.

I'm currently attempting option C, however I'm having some other problems at runtime with that that I can't seem to put a finger on the source of...

If anyone has any advice on how I could proceed with this, help would be greatly appreciated.

like image 614
Rob Giusti Avatar asked Sep 15 '26 15:09

Rob Giusti


1 Answers

We were reaching this particular problems ourselves. We traced the problem down to the source code of RabbitMQ's CreateConnectionFactory call. For v3.2 of the rabbitmq client of the stable branch, the problem was traced to be in the constructor of SocketFrameHandler_0_9 class located in src/client/impl of the RabbitMQ.Client assembly. The line causing this crash was the property invocation of Socket.OSSupportsIPv6. By commenting the particular line and fixing the socket connection to be IPv4 we managed to solve the problem. We hope that this helps someone.

like image 159
aldoum iti Avatar answered Sep 18 '26 04:09

aldoum iti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!