Connecting to friend's host server with real IP addresses

I noticed that there are plenty of tutorials how to set up a simple multiplayer game by using two windows (one with editor in game mode and another from built game mode). However, I got stuck at the start when I am trying to set up real connection with my friend, who uses computer from remote place (lets assume that my friend is not on the same LAN as me, e.g. lives somewhere in different country). More particular questions here are:

  1. How to properly find my and my friend’s IP address and port which we could use for setting up host server on one of our computers? (I remember there can be also internal and external IP addresses).

  2. When we both find these IP addresses and ports, where we should enter them to properly set up master server and connection?

Disclaimer: I’m still learning the networking too - and haven’t tested online play only because I haven’t progressed far enough yet.

Anyway yeah just for testing and everything, you can direct connect through IP and port (assuming the appropriate port is forwarded on the firewall/router/modem) by just contacting someone, have them go to whatismyip.com and give you the public ip to them. Then either in your code decide a default port or enter it when starting a server through the gui or something - and hand the port and IP off when you start up the server, or connect the client.

Now for release - that’s a whole 'nother ball game! You better have some kind of master server who every player announces themselves to when they start a match. This way players can browse all active servers, through some gui magic. That is only the start though - you need NAT punch through to help players (especially mobile devices) get past firewalls/routers/gateways/modems or whatever other network issue is going on through the interwebs. This is possible (supposedly, I haven’t tried) through the new service unity offers, which the name escapes me right now, but is free for us to test for the time being that helps with matchmaking.

Hope I scratched the surface at least on those topics lol.

Good luck!

Hi guys, I’m struggling with this step right now. I’m trying to test using my own a friend’s IP address but the editor tries and eventually does not connect. No errors. Any ideas?

I started to use Unity’s Matchmaker system and it seems to work well, no IPs needed to find or enter, matchmaker just finds the host room and the client can connect to it. Try it, I guess it’s an easy way to get started.

Thank you! That makes sense.

System.FormatException: FAILURE Returned from server: Failed because of invalid projectid setup. Please verify project setup at https://multiplayer.unity3d.com.

When I set up a project on https://multiplayer.unity3d.com do I use the UPID, Project Name or other as the room name?

I just used the cloud button in the Unity to connect project after I set up things in https://multiplayer.unity3d.com . But I did it long time ago, so it may work a bit differently now. Check the top lines here, it explains how to set up matchmaker: http://docs.unity3d.com/Manual/UNetInternetServicesOverview.html

Ok, this is where I got hung up. In the video it shows him putting the product ID into a field in player setting instead of clicking on the cloud icon.

The problem now is that the cloud icon does nothing. I have a services tab open, I"m logged into my account but nothing shows up. Do I have to be a pro user to use this service?

Thank you!

Nevermind my last reply. I did what you suggested and it worked with a couple little hang-ups.

I’ll list the steps here in case anyone else gets stuck.

Go to Unity Editor and click the cloud button 4th from the upper right corner.

This will bring up a services tab. I got stuck here because nothing was showing up (do I need to be a pro user, why is it blank?).

I restarted unity and the services tab showed the projects I had set up in https://multiplayer.unity3d.com. (See below).

I selected the organization (my username), my project name, and then my unity project Id.

Thank you.2716235--192747--Capture.PNG 2716235--192748--Capture2.PNG

Great that you solved it. Now the most important thing is to check if it actually works between two separate computers, which are not on the same LAN (I would start with simplest player movement sync’ing to see if it works).

I ran into a similar problem as yours a month or so ago. For me it was due to the way my router was hooked up, and I fixed it using this awesome asset from the asset store. You may be having a different problem than I- but if you continue having issues, check out my thread from a while back.

Where you able to play with your friend using Unitys Matchmaking service?

This thread is 7 years old :roll_eyes:

Anyway, you cant use it now, since its deprecated.
A combination of lobby and relay is now the official way of doing it.

Could you elaborate or refer me the link to the official way?
Thanks

https://blog.unity.com/games/empower-great-multiplayer-experiences-with-relay-and-lobby?utm_source=blog&utm_medium=social&utm_campaign=community_global_generalpromo_2022-03-09_blog-empower-great-multiplayer-experiences-with-relay-and-lobby