Network problem when building the game

Hello,
I’m working now for a few months in Unity and started a new project for a network/online game. I used the tutorial of M2H, and used a script of one of the example’s and changed it a little bit and then builded it. Tested it with with a friend over the internet and it worked.

I decided to expand it a little with a nice menu. builded it again, tested it over internet but now i’m getting an error :

A client which was not in the connected player list disconnected. ???

So i had a connection but disconnected immediately? i couldn’t find anything that was cousing this error so i deleted all script exept the one that worked in the beginning tryed to build it and do it over internet but same error did it local but same error even in a new project with same starting script i’m getting this error and now even my other project (not over internet) gets this error?

I can’t find anything helpfull on the internet so if you could help.

The code that I am using :

#pragma strict
#pragma implicit
#pragma downcast

var connectToIP : String = "127.0.0.1";
var connectPort : int = 25001;
var ConnectPassword : String = "";

function OnGUI ()
{

	if (Network.peerType == NetworkPeerType.Disconnected){//hierdoor zie je dat je disconnected bent

		GUILayout.Label("Connection status: Disconnected");//hierdoor zie je dat je disconnected bent
		
		connectToIP = GUILayout.TextField(connectToIP, GUILayout.MinWidth(100)); // ip invullen
		connectPort = parseInt(GUILayout.TextField(connectPort.ToString())); // port invullen
		ConnectPassword = GUILayout.TextField(ConnectPassword, GUILayout.MinWidth(200));
		
		GUILayout.BeginVertical();
				if (GUILayout.Button ("Connect as client")) {//zorgt er voor dat je met de server connect
					Network.Connect(connectToIP, connectPort, ConnectPassword);} //connect met ingevulde ip en port
				//, ConnectPassword
				if (GUILayout.Button ("Start Server")){
					Network.incomingPassword = "HolyMoly";
					Network.InitializeServer(32, connectPort,false);}
		GUILayout.EndVertical();
		
		
	}else{//probeert connectie te maken
		if (Network.peerType == NetworkPeerType.Connecting){
			GUILayout.Label("Connection status: Connecting");
			
			// geconnected als client
		} else if (Network.peerType == NetworkPeerType.Client){
			GUILayout.Label("Connection status: Client!");
			GUILayout.Label("Ping to server: "+Network.GetAveragePing(  Network.connections[0] ) );		
			
			
			//je bent de server
		} 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 (GUILayout.Button ("Disconnect")){
			Network.Disconnect(200);}
			
	}
}

Thanks,

Ruben,

Nobody? i am still stuck i can’t find the problem… thanks in advance :wink:

did you set ‘Application.runInBackground = true;’ when you build the game ?

i´m having the same problem , i will try appels´s suggest, but that must to be set on any script?.. or is the checkbox option in player inspector?=

call it in the awake of the first script that gets executed

thanks!

I have seen this a few times when testing Unity Networking as I follow Leepo’s tutorials (Ultimate Unity Networking project - Add multiplayer to your game today! - Unity Engine - Unity Discussions).

I’m unclear what setting Application.runInBackground = true in Awake() will do if you’ve set that in player settings, as I assumed it was the same thing:

“Should the player be running when the application is in the background?”

“Run in background Check this if you dont want to stop executing your game if it looses focus.”

yes!, i was meaning about the checkbox in player inspector when you build a webplayer… … i haven´t tested yet but i guess i will be solved…