- Home /
how to catch Network.InitializeServer errors?
Hi,
I am a bit puzzled by this, hopefully this is just something silly:
I am not connected to the internet and I try to use Network.InitializeServer and I am getting the following:
try
{
var error = Network.InitializeServer(32, 25001, true);
Debug.Log(error);
}catch(System.Exception e)
{
Debug.Log("catched error : "+e.Message);
}
I get the following error:
Cannot resolve facilitator address, make sure you are connected to the internet before connecting to a server with NAT punchthrough enabled UnityEngine.Network:InitializeServer(Int32, Int32, Boolean)
So if the user is not connected to the internet, How can I efficiently detect this end prevent errors? because Application.internetReachability is not reliable,
Thanks for your help,
Jean
Answer by jonomf · Oct 19, 2012 at 07:59 AM
InitializeServer returns a NetworkConnectionError, so you'll want to check that it == NetworkConnectionError.NoError, else: do your error handling.
Don't worked for me.
The Network.InitializeServer always gives me NetworkConnectionError.NoError. But, after some seconds (~5s), unity triggers the OnFailedToConnect function / event.
Currently I am waiting for about this amount of time (with yield return new WaitForSeconds(5)) to check if the event will be triggered or not, to show an error for the player or to move on in the game. However, I suppose this is not the best way to do it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613065329im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to put Networkview.isMine in mouselook 0 Answers
Network.Connect returns NoError but no connection? 0 Answers
Network errors and update failures 1 Answer
Unity Multiplayer errors?! 0 Answers