diff --git a/Assets/Mirror/Runtime/Transport/TelepathyTransport.cs b/Assets/Mirror/Runtime/Transport/TelepathyTransport.cs index fa1ed22e0..a2b86e6c4 100644 --- a/Assets/Mirror/Runtime/Transport/TelepathyTransport.cs +++ b/Assets/Mirror/Runtime/Transport/TelepathyTransport.cs @@ -1,6 +1,7 @@ // wraps Telepathy for use as HLAPI TransportLayer using System; using System.ComponentModel; +using System.Net.Sockets; using UnityEngine; using UnityEngine.Serialization; @@ -126,7 +127,25 @@ public bool ProcessServerMessage() return false; } public override bool ServerDisconnect(int connectionId) => server.Disconnect(connectionId); - public override string ServerGetClientAddress(int connectionId) => server.GetClientAddress(connectionId); + public override string ServerGetClientAddress(int connectionId) + { + try + { + return server.GetClientAddress(connectionId); + } + catch (SocketException) + { + // using server.listener.LocalEndpoint causes an Exception + // in UWP + Unity 2019: + // Exception thrown at 0x00007FF9755DA388 in UWF.exe: + // Microsoft C++ exception: Il2CppExceptionWrapper at memory + // location 0x000000E15A0FCDD0. SocketException: An address + // incompatible with the requested protocol was used at + // System.Net.Sockets.Socket.get_LocalEndPoint () + // so let's at least catch it and recover + return "unknown"; + } + } public override void ServerStop() => server.Stop(); // common