• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android Can't connect with 4G connection.

Hazuki

Member
Hi, I've trying around with networking system between Android and Windows.

The strategy is this : Server.exe is in my computer and constantly running, then player (only Android app, not Windows) can connect to it.

The connection with Wi-fi (in Android) worked fine, declaring Server side local IPv4 address(which starts from 192-) from Client side(Android apps).
However, when i switch to 4G connection, it doesn't connect to the Server.exe. Is there any way to resolve this?

edit: It also doesn't connect with another Wi-Fi.
 
Last edited:

FrostyCat

Member
192.168.x.x addresses are NAT private addresses, they only have meaning within the same subnet. If you want the server to be visible from outside the LAN, you need to find the router's public IP address and also set up port forwarding, both of which can be done through your router if you have admin access to it.

I just wish people would learn some basic network administration before attempting an online networked game. It's incredibly tiresome having to explain this on the Q&A time and time again, when this knowledge should have been part of a sensible education on the subject.
 

Hazuki

Member
Thank you for the answering FrostyCat!
Actually, I made it! Now I could connect client side and server side even in 4G or other Wi-Fi.

For anyone who watch this thread because of the same problem, I leave the method for Windows10.
Note that I'm a beginner in networking so something might be wrong, someone who notice that, please leave the post.
For now, I'll just set the port to 4321.

First, you need to port forwarding. You have to set up your router to do it.
The method for this is really depends on your router. Check out the manual or the website.
For me, I typed in the ip address what the manual says in url. Then type in username and password. Mostly, username is "admin".
Login and find port forwarding settings, typing in your ip address and the port. Something like that.

Second, you need to setting up firewall for port forwarding.
Control Panel > System and Security > Windows Defender Firewall > Advanced settings > Ringt Click the Inbound Rules . Press New Rule > Select Port and press Next > TCP, Specified local port and tipe in 4321 > Allow the connection > only Private > Type the Name whatever you want > Finish.
Same as the Outbound Rules.

Last, Setting up in Gamemaker.
In Server.yyp, create a obj_server.
in Create event:
Code:
server_port = 4321;
clientNum = 4;
server = network_create_server(network_socket_tcp,server_port,clientNum);
In Game End event:
Code:
network_destroy(server);
Then switch to Cilent.yyp.
In Create Event:
Code:
var type = network_socket_tcp;
var ip = "Your global IP address";
var port = 4321;

socket = network_create_socket(type);
network_connect(socket,ip,port);
Then test it out. First run Server in your computer and then run Client in another computer or your phone.
Note that Server side computer and Client side devices are not using same Wi-Fi. It didn't connect in my case.

Also you need to know whether it is connected or not.
In obj_server, add Async-Networking event:
Code:
var type = async_load[? "type"];

if(type == network_type_connect){
show_debug_message("ip = " + string(async_load[? "ip"]));
        show_debug_message("id = " + string(async_load[? "id"]));
        show_debug_message("socket = " + string(async_load[? "socket"]));
}
above code will tell us it is connected or not by showing some debug message.


That's all I know. Again, It might not be the best way, I'm just telling what I did for it.
 
Top