We are make a shooting game use NAT punchthrough, I am testing the Symmetric to Symmetric connection. I get the follow error message in Editor,
“Receiving NAT punchthrough attempt from target 1040331542722064946 failed”
“Error in NetworkManager.cpp line 809”
But there is no error Notify in
void Network.OnFailedToConnect(NetworkConnectionError error);
I want to tell the client with a message popup this time, but where can I catch the error?!
We have found a very hacky solution to this problem. It’s not pretty, but it works.
We have registered a log callback using
Application.RegisterLogCallback(LogCallback)
and in the callback code checking if the error string matches what Unity prints,
private void LogCallback(string condition, string stackTrace, LogType type)
{
if (type == LogType.Error)
{
// Check if it is the NATPunchthroughFailed error
const string MessageBeginning = "Receiving NAT punchthrough attempt from target";
if (condition.StartsWith(MessageBeginning, StringComparison.Ordinal))
{
// Call the callback that Unity should be calling.
OnFailedToConnect(NetworkConnectionError.NATPunchthroughFailed);
}
}
}
I reported this error to Unity a few months ago, but have not received any feedback on it yet. (The case id is 487268 if anyone from Unity likes to look it up.)