Getting NotImplementedException: The method or operation is not implemented.
System.Net.NetworkInformation.UnixIPGlobalProperties.GetActiveUdpListeners () (at <>:0) when going through the GameLift Mega Frog Tutorial, when I try to connect to or create a server. Can’t figure out what I need to do here. This should be implemented in the .dll that the tutorial is using, right?
Can you confirm your OS and Unity version?
I am going to assume you are on Mac OS X and are seeing issues in FindAvailableUDPPort
Looks like Unity is trying to link against this:
and it appears Mono on Unix platforms just doesn’t implement this feature.
As the Megafrog code is just trying to find an open UDP port, the workaround here is fairly straightforward. You could either:
- Return a hard-coded UDP open port
- Use the examples here (which reference TCP but many should work with TCP) to build alternative code: https://stackoverflow.com/questions/138043/find-the-next-tcp-port-in-net
- The example from Eric Boumendil should be easy to modify to use Udp
- Basically rely on the properties of port 0, and the network adapters should find you the next open port
I have filed an internal bug to fix the example on Mac OS X. Apologies for the inconvenience.
Better fix: GameLift Server kicks player because of no response to ping
(Only just seen - we’re obviously going through the same issue at the same time!)
As of Sept 2020, this is still in the sample code. Here is a simple fix based on Pip’s details above.
Replace the function “FindAvailableUDPPort” with
private int FindAvailableUDPPort(int firstPort, int lastPort)
var UDPEndPoints = IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners();
List<int> usedPorts = new List<int>();
usedPorts.AddRange(from n in UDPEndPoints where n.Port >= firstPort && n.Port <= lastPort select n.Port);
for (int testPort = firstPort; testPort <= lastPort; ++testPort)
Debug.Log("You must be on a Mac or Unix");
TcpListener l = new TcpListener(IPAddress.Loopback, 0);
int port = ((IPEndPoint)l.LocalEndpoint).Port;
You’ll need to add references for System.Net (‘using System.Net’) as the top.