Godot: Android - Networking does not work

Created on 24 Nov 2019  路  5Comments  路  Source: godotengine/godot

Godot version:
3.2 Beta 2

OS/device including version:
Android 10, Build QP1A.191105.003
Google Pixel 3a

Issue description:
Networking does not work on Android... Prints errors

Code:

func _ready():
    var server = NetworkedMultiplayerENet.new()
    server.create_server(8200)
    get_tree().network_peer = server
    rpc_id(1, "test") # Test if things are working

master func test():
    print("Success")

Errors:

11-24 13:26:19.124  8441  8491 E godot   : **ERROR**: Condition ' _sock == -1 ' is true. returned: FAILED
11-24 13:26:19.124  8441  8491 E godot   :    At: drivers/unix/net_socket_posix.cpp:328:open() - Condition ' _sock == -1 ' is true. returned: FAILED
11-24 13:26:19.124  8441  8491 E godot   : **ERROR**: Condition ' !is_open() ' is true. returned: ERR_UNCONFIGURED
11-24 13:26:19.124  8441  8491 E godot   :    At: drivers/unix/net_socket_posix.cpp:382:bind() - Condition ' !is_open() ' is true. returned: ERR_UNCONFIGURED
11-24 13:26:19.124  8441  8491 E godot   : **ERROR**: Condition ' !host ' is true. returned: ERR_CANT_CREATE
11-24 13:26:19.124  8441  8491 E godot   :    At: modules/enet/networked_multiplayer_enet.cpp:107:create_server() - Condition ' !host ' is true. returned: ERR_CANT_CREATE
11-24 13:26:19.124  8441  8491 E godot   : **ERROR**: Supplied NetworkedNetworkPeer must be connecting or connected.
11-24 13:26:19.124  8441  8491 E godot   :    At: core/io/multiplayer_api.cpp:153:set_network_peer() - Condition ' p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED ' is true.
11-24 13:26:19.124  8441  8491 E godot   : **ERROR**: Trying to call an RPC via a network peer which is not connected.
11-24 13:26:19.124  8441  8491 E godot   :    At: core/io/multiplayer_api.cpp:637:rpcp() - Condition ' network_peer->get_connection_status() != NetworkedMultiplayerPeer::CONNECTION_CONNECTED ' is true.

Steps to reproduce:

  1. Place the code in a project
  2. Run on Android

Minimal reproduction project:
TestNoMono.zip

documentation android network

Most helpful comment

@lawnjelly Thanks! This was the problem (Missing "Internet" permission)
Is there a discussion issue about preventing this in the future? I think there should be a warning when exporting to Android if any classes being used may require a permission not given

All 5 comments

Does the equivalent GDScript code work?

Thank you for the response, the bug still occurs in GDScript and therefore I should edit my issue to reflect that.

Wild guess, could it be permissions? Have you exported with permissions to do networking? (I only say this because it is a common gotcha on Android)

@lawnjelly Thanks! This was the problem (Missing "Internet" permission)
Is there a discussion issue about preventing this in the future? I think there should be a warning when exporting to Android if any classes being used may require a permission not given

@nathanwfranke add control mechanism to check which permissions need to be exported can maybe too complicated. Because there are so many code in mobile devices side and there can be so many code in godot side(I refer mobile and godot side because this check could be for 2 sides.)But for this case internet permission can be added default. For a long time google do not ask permission request for Internet.

Was this page helpful?
0 / 5 - 0 ratings