Proxy, how do you use it?

After looking over the Unity3d website, I have not been able to find a good report on how to use or what proxy is. I ask of the users of the form to please explain it. I hope this may also benefit future users who have the same question.
:face_with_spiral_eyes::face_with_spiral_eyes::face_with_spiral_eyes:
What is proxy?
What does it require?
How can I implement it to a game?
:face_with_spiral_eyes::face_with_spiral_eyes::face_with_spiral_eyes:
I do have one script to show: ( I got this from the Resources and Mike Hergaarden’s zero to hero guide)

var imaserver: boolean;
var serverIP = “1.1.1.1”;
var serverPort = 25001;
var serverUsesNAT: boolean;
var Player : Transform;

function Awake()
{
// Set custom proxy server address
Network.proxyIP = serverIP;
Network.proxyPort = serverPort;
}
function OnGUI(){

if (Network.peerType == NetworkPeerType.Disconnected){
//We are currently disconnected: Not a client or host
GUILayout.Label(“Connection status: Disconnected”);

serverIP = GUILayout.TextField(serverIP, GUILayout.MinWidth(100));
serverPort = parseInt(GUILayout.TextField(serverPort.ToString()));

GUILayout.BeginVertical();
if (GUILayout.Button (“Connect as client”))
{
//Connect to the “connectToIP” and “connectPort” as entered via the GUI
//Ignore the NAT for now
ConnectToServerWithProxy();
Network.Instantiate(Player, Vector3.zero, Quaternion.identity, 83);
//Network.useProxy = true;
}
if (GUILayout.Button (“Start Server”))
{
//Start a server for 32 clients using the “connectPort” given via the GUI
//Ignore the nat for now

Network.InitializeServer(32, serverPort);
}
GUILayout.EndVertical();

}else{
//We’ve got a connection(s)!

if (Network.peerType == NetworkPeerType.Connecting){

GUILayout.Label(“Connection status: Connecting”);

} else if (Network.peerType == NetworkPeerType.Client){

GUILayout.Label(“Connection status: Client!”);
GUILayout.Label("Ping to server: "+Network.GetAveragePing( Network.connections[0] ) );

} else if (Network.peerType == NetworkPeerType.Server){

GUILayout.Label(“Connection status: Server!”);
GUILayout.Label("Connections: "+Network.connections.length);
if(Network.connections.length==1){
GUILayout.Label("Ping to first player: "+Network.GetAveragePing( Network.connections[0] ) );
}
if(Network.connections.length==2){
GUILayout.Label("Ping to second player: "+Network.GetAveragePing( Network.connections[1] ) );
}
}

if (GUILayout.Button (“Disconnect”))
{
Network.Disconnect(200);
}
}

}
if (imaserver)
{
StartServerWithProxy();
}
else
{
ConnectToServerWithProxy();
}

function StartServerWithProxy()
{
Network.useProxy = true;
Network.InitializeServer(32 ,Network.proxyPort);
}
function OnServerInitialized(player: NetworkPlayer)
{
if (Network.useProxy)
Debug.Log ("Successfully started server with proxy support. We are connectable through "

  • player.ipAddress + “:” + player.port);
    }

function OnFailedToConnect(msg: NetworkConnectionError)
{
if (Network.useProxy imaserver)
{
Debug.LogError("Failed to connect to proxy server: " + msg);
}
}

function ConnectToServerWithProxy()
{
Network.useProxy = true;
Network.useNat = serverUsesNAT;
Network.Connect(serverIP, serverPort);
}

function OnConnectedToServer()
{
Debug.Log(“Connected successfully to server”);
}

The documentation doesn’t say much, but from my I.T. days, here is what I would guess.

A proxy server is what you would typically see at a school or business to protect inner PCs from WAN traffic. There are several other features too, it can sort of guide traffic too, called port fowarding.

If there were a proxy server in between you and the internet, I’m guessing you need to specify that it is there, and what port to send data on-- which might not necessarily be what y ou receive on.

So, your Unity game might be sending data to 24.63.10.150, but it might have a travel path more like:

127.0.0.1 -> 192.168.1.1 //your PC to proxy
192.168.1.1 -> 10.0.10.0 //your proxy to cable modem
10.0.10.0 -> various DNS servers //cable modem to internet
various DNS servers -> 24.63.10.150 //internet to main server
[code]

To complicate things, it is entirely possible that you your code may be sending on port 27015, but that may be blocked on your proxy for some reason. So, you might have to change some ports around on the proxy, and map incoming traffic on port 27018 to go outbound on 27015 (the same is true for receiving-- traffic could come in on 9110, but be mapped to your PC on 110-- we used to do things like that for remotely connecting into PCs from 'outside').

You might not have to do some of the above though depending on how your proxy server is set up.

Good luck, and I hope that helps!

Wow, i’m going to have to say I don’t still get it. It’s not that you didn’t explain well. But it is just to complicatied for me :slight_smile: . So now I ask, would LAN be better?

It is a very complicated subject, and for the general case, I would suggest avoiding using the proxy server since you won’t have one unless you are the server.

I’d recommend reading (and struggling) through a book on basic networking.

LAN is tough too?

for LAN you would either use UDP Broadcast to find servers (and check for them on the servers to answer) or to promote servers (then clients no directly where to go to).

you can then basically cut the whole master server part if you are within the local LAN only (always assuming you don’t have firewalls even in the local lan, shielding stuff off)

Ok so all I need to do is get/make a master server? No I am not on local.

you need to have a (virtual) dedicated server thats reachable from internet that hosts master server- connection tester - nat facilitator and proxy (thats all 1 package and 2-3 apps you need to compile), but yes thats basically is. you could host it from home on an own box too given you can fullscale portforward the ports to that machine

for your own testing purposes you can use proxifier, it integrates into applications.
but if you want to achieve proxy by coding, then never mind, just passing by, throwing 0.02$

So, to host it form home I basiclly need a master server, connection tester, and facilitator.

I downloaded the unity master server. but I don’t know what to do with it now.

The scripting reference has a net tester, but it has to many errors, anyone of you have a preferance?

And of course I don’t know how to use a facilitator. I know that some people are required to connect to it because of thier firewall settings.

function OnGUI()
{
if(GUI.Button (Rect (10, 70, 100, 30), “Server”))
{
StartServer();
}
if(GUI.Button (Rect (10, 100, 100, 30), “Client”))
{
Connect();
}
}
function StartServer() {
Network.InitializeServer(32, connectPort);
MasterServer.dedicatedServer = true;
MasterServer.updateRate = 0;
MasterServer.RegisterHost(“MMORPG”,“World of Kamea”, “Death to the monsters!”);
}
function Connect() {
Network.Connect(connectToIP, connectPort);
/Network./Instantiate(Player, transform.position, Quaternion.identity/, 32/);
}
What can this do? Yes I wrote it with the help of the unity website. But I hardly know how I can use it.

Does the master server script(above) automaticly interact with the unity master server if I type in the master server’s ip?

Okay, I got connection ( with my self, on my own computer). But to start, I need to be able to see client and server. They can only se them selves. I used Network.Instantiate, and they have network views on them, the cameras and audio listeners are working fine. Just need to make it so they can see each other, then i’ll need help moving on to bigger things like wireless connection.

I can get myself to connect but…

  • Only works with 127.0.0.1 : Any port that has a server
  • Everyone controls everyone!
  • Some help please?

So… I found a youtube video by thenewboston aboutnetworking. At this point I have only watched one ofthe videos. But I already learned that most people are not lookingfor LAN. But WAN is way better. MAN is useless.