简体   繁体   English

在使用Mono / Unity3D的Android设备上使用RabbitMQ的问题

[英]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. 我正在使用Unity3D制作游戏,并尝试将其部署到Android和iOS设备。 I'm using RabbitMQ/AMQP to communicate with a server for online play. 我正在使用RabbitMQ / AMQP与服务器进行在线播放通信。

When I run my game in the Unity editor and on iOS devices, all of the networking code works fine. 当我在Unity编辑器中和iOS设备上运行游戏时,所有网络代码都可以正常工作。 However, when I deploy to Android devices there seem to be issues with some of the .NET libraries agreeing with RabbitMQ. 但是,当我部署到Android设备时,某些与RabbitMQ一致的.NET库似乎出现了问题。

When the game is first run (and the connection to the server is being established), I get the following error in my logcat: 首次运行游戏(并建立与服务器的连接)时,我的logcat中出现以下错误:

E/Unity ( 5378): Connection exception: None of the specified endpoints were reachable E / Unity(5378):连接异常:指定的端点均不可达
E/Unity ( 5378): Endpoints attempted: E / Unity(5378):尝试的端点:
E/Unity ( 5378): ------------------------------------------------ E / Unity(5378):------------------------------------------- -----
E/Unity ( 5378): endpoint=amqp-0-9://robot.lvl6.com:5672, attempts=1 E / Unity(5378):端点= amqp-0-9-9://robot.lvl6.com:5672,尝试次数= 1
E/Unity ( 5378): System.EntryPointNotFoundException: getifaddrs E / Unity(5378):System.EntryPointNotFoundException:getifaddrs
E/Unity ( 5378): at (wrapper managed-to-native) System.Net.NetworkInformation.LinuxNetworkInterface:getifaddrs (intptr&) E / Unity(5378):位于(包装由本机管理)System.Net.NetworkInformation.LinuxNetworkInterface:getifaddrs(intptr&)
E/Unity ( 5378): at System.Net.NetworkInformation.LinuxNetworkInterface.ImplGetAllNetworkInterfaces () [0x00000] in :0 E / Unity(5378):位于System.Net.NetworkInformation.LinuxNetworkInterface.ImplGetAllNetworkInterfaces()[0x00000] in:0
E/Unity ( 5378): at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces () [0x00000] in :0 E / Unity(5378):位于System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0x00000],其中:: 0
E/Unity ( 5378): ================================================ E /统一(5378):============================================ =====
E/Unity ( 5378): Stack trace: E / Unity(5378):堆栈跟踪:
E/Unity ( 5378): at RabbitMQ.Client.ConnectionFactory.CreateConnection (Int32 maxRedirects) [0x00000] in :0 E / Unity(5378):位于:0的RabbitMQ.Client.ConnectionFactory.CreateConnection(Int32 maxRedirects)[0x00000]
E/Unity ( 5378): at RabbitMQ.Client.ConnectionFactory.CreateConnection () [0x00000] in :0 E / Unity(5378):位于:0的RabbitMQ.Client.ConnectionFactory.CreateConnection()[0x00000]
E/Unity ( 5378): at UMQNetworkManager.Start () [0x0009a] E / Unity(5378):位于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. 现在,我已经能够找到这个帖子关于与GetAllNetworkInterfaces()的问题,但我有困难,搞清楚如何从这里向前迈进。

Is there some way to easily work around getifaddrs not being accessible on Android through Mono? 有什么方法可以轻松解决无法通过Mono在Android上访问的getifaddrs吗? 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. 否则,此时我的选择似乎是(A)为我的客户端的Android版本使用其他AMQP库,(B)修改RabbitMQ的源并以允许我获取它的方式重新编译它无需getifaddrs就可以工作,或者(C)包括Java版本的RabbitMQ的.jar,并使用Unity的AndroidJavaObject类通过JNI访问RabbitMQ框架。

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... 我目前正在尝试选项C,但是在运行时遇到了其他一些问题,这些问题似乎使我无法理解...

If anyone has any advice on how I could proceed with this, help would be greatly appreciated. 如果有人对我如何进行此工作有任何建议,将不胜感激。

We were reaching this particular problems ourselves. 我们自己正在解决这个特殊问题。 We traced the problem down to the source code of RabbitMQ's CreateConnectionFactory call. 我们将问题追溯到RabbitMQ的CreateConnectionFactory调用的源代码。 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. 对于稳定分支的rabbitmq客户端的v3.2,该问题可追溯到位于RabbitMQ.Client程序集的src / client / impl中的SocketFrameHandler_0_9类的构造函数中。 The line causing this crash was the property invocation of Socket.OSSupportsIPv6. 导致此崩溃的行是Socket.OSSupportsIPv6的属性调用。 By commenting the particular line and fixing the socket connection to be IPv4 we managed to solve the problem. 通过注释特定的行并将套接字连接固定为IPv4,我们设法解决了该问题。 We hope that this helps someone. 我们希望这对某人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM