Godot Multiplayer IP address to connect to

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Abhi4124

Hi,
I have made a game and it uses peer to peer and it’s working fine in local host on my pc using 192.168.1.2 etc but when i export it and use it on different Network other than my wifi network it doesn’t work. It works only if i connect both devices to same wifi. How do i connect via internet. What is the ip that should be used to connect to ?

Thanks !

Hi, i don’t know if i understood you correctly, but you want to run the game in a computer, and connect to it from another computer connected to a different network? Then, how do you reach the computer that is serving the game?

As far as i know, the server of the game must be reachable for all the computers that try to connect. So, unless you have a public server on internet, and you host your game there, you will not be able to play across the internet. Two computers in different networks each one with a private Ip address cannot see each other.

p7f | 2018-12-26 13:30

So two different players cant connect via thier ip? Is there any tutorial on having a dedicated server ?

Abhi4124 | 2018-12-26 13:42

Two different players can connect via their ip as long as the one is being server has public ip address, or they are connected at the same network (it can be a vpn also, if you do not have a public server). You should get familiar with private and public IP and some networking before attepmting to do such thing as an online game.

Another thing you can try is to serve the game in your local computer, and make a port forwarding in your router so others can connect to the public ip (you can find it with https://www.myip.com/) and let other players to connect to that ip and the port you forwarded in the router. The problem is that your ISP is likely going to change your ip from time to time, and the players will have to change to where they are connecting.

About the tutorial, i could not find anyone, but in a few months i will try. If you still need it then i’ll post it here unless someone else solved your issue.

p7f | 2018-12-26 14:24

Hi, maybe this helps.

p7f | 2018-12-26 14:30

I gave my IP to my friend and a game is hosted in my pc but he cant connect. I have already tried this thats why i asked for help. Thanks

Abhi4124 | 2018-12-29 14:55

Please post the Tutorial here Please

Abhi4124 | 2018-12-29 14:57

Well, you gave your friend your ip… what what ip? your public ip given by your ISP to you, which is usually dynamic? If so, you may do a port forward. If you are telling me that you gave him the private ip you get from your computer an your friend is on a different network, that is not going to work.

p7f | 2018-12-30 01:33

I gave him the same ip which I get from the website which i think is a ipv4 address I think and it changes rarely on modem restart

Abhi4124 | 2018-12-30 01:51

I used my Private ip to test within my network and it works perfectly fine. The only problem is over the internet connection. If i have to do a port forward then what about other users who will be using the final build. Not everyone had a modem too some uses mobile data

Abhi4124 | 2018-12-30 06:39

First, the port forwarding is only done in your router… Other people just need to put the public IP you give them, and the port which is forwarded to the port of the game on your local machine. So your router has a PublicIP and your machine has a PrivateIP, and the server started in your game has a ServerPORT. You CAN’T reach your private IP and ServerPORT on it, if you are not in the same network. So what you do is foward a port of your choice between the private ports (lets call it RouterPORT), to the PrivateIP of your machine and the ServerPORT. Then, the user has to connect to the PublicIP and RouterPORT, and the router will forward it to PrivatIP and ServerPORT.

what about other users who will be using the final build

This is explained above, but, are you saying that you are going to give the game to other users you don’t know? I mean, are you going to distribute this game? If so, i would say you definitly need a dedicated server, install ther the server instance of the game, and the users should connect there. If a lot of work if you are not quite familiar with servers and TCP/IP connections.

p7f | 2018-12-30 14:41

Okay that’s why i asked for some tutorial. I need to setup a server build of the game but the game is a 1v1 game and there will be users in a particular match and only 2 players in a single game. how can i achieve that?

Abhi4124 | 2018-12-30 18:02

Do you know how to use Firebase Real time Database with Godot? If yes can you tell

Abhi4124 | 2018-12-30 19:56

Setting up a server is nothing trivial. But may be this link i provided before helps you. You should get a dedicated server and then do that.

If i manage to do this anytime i will post it here… I hope i can!

p7f | 2018-12-30 19:57