-->

Connecting Unity3d Android application to ActiveMQ

2020-08-03 07:17发布

问题:

I am trying to connect an Unity3d Android application to an ActiveMQ server using MQTT protocol.

In the log attached below I can see that the server is refusing me the connection.

I have correctly portforwarded the required port to be accessible from outside. I have also tried to connect from the local network using the device's wi-fi.

I am using a MQTT library for unity which can be found here: https://m2mqtt4unity.codeplex.com/

Currently the same application, the example that can be found in https://m2mqtt4unity.codeplex.com/documentation, is working fine in the unity editor and in standalone (.exe). I have correctly set the activemq protocol settings to allow MQTT.

I have posted other question about connecting to activeMQ using NMS here: Subscribing to ActiveMQ from Unity3D app on Android.

Using "adb logcat -s Unity" to debug throws this:

--------- beginning of /dev/log/system

--------- beginning of /dev/log/main

E/Unity   (12824): Unable to find AudioPluginOculusSpatializer

D/Unity   (12824):  GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage GL_EXT_multisampled_render_to_texture GL_OES_surfaceless_context GL_EXT_shader_pixel_local_storage GL_ARM_shader_framebuffer_fetch GL_ARM_shader_fram

D/Unity   (12824): ebuffer_fetch_depth_stencil GL_ARM_mali_program_binary

I/Unity   (12824): SocketException: Connection refused

I/Unity   (12824):   at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP, Boolean requireSocketPolicy) [0x00000] in <filename unknown>:0 

I/Unity   (12824):   at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0 

I/Unity   (12824):   at uPLibrary.Networking.M2Mqtt.MqttNetworkChannel.Connect () [0x00000] in <filename unknown>:0 

I/Unity   (12824):   at uPLibrary.Networking.M2Mqtt.MqttClient.Connect (System.String clientId, System.String username, System.String password, Boolean willRetain, Byte willQosLevel, Boolean willFlag, System.String willTopic, System.String willMessage, Boolean cleanSession, UInt16 keepAlivePeriod) [0x00000] in <filename unknown>:0 

I/Unity   (12824): Rethrow as MqttConnectionException: Exception connecting to the broker

I/Unity   (12824):   at uPLibrary.Networking.M2Mqtt.MqttClient.Connect (System.String clientId, System.String username, System.String password, Boolean willRetain, Byte willQosLevel, Boolean willFlag, System.String willTopic, System.String willMessage, Boolean cleanSession, UInt16 k