AWS re:Post을(를) 사용하면 다음에 동의하게 됩니다. 이용 약관

GameLift multiple processes can not detect open ports on Windows Server

0

I want to be able to run multiple processes in a GameLift fleet. When I test with gamelift locally, the following code can find the next open port on my machine (Windows). Concurrent server.exe processes will open on consecutive ports if one is in use, and are passed to the GameLift Server. In an actual GameLift fleet, however, multiple processes are trying to start on the same port (5000). I have the fleet port settings open between 5000-5500 for TCP and UDP.

public static ushort GetFirstOpenUdpPort(int startingPort, int maxNumberOfPortsToCheck)
    {
        var range = Enumerable.Range(startingPort, maxNumberOfPortsToCheck);

        var portsInUse =
            from port in range
            join used in System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners()
            on port equals used.Port
            select port;

        var firstFreeUdpPortInRange = range.Except(portsInUse).FirstOrDefault();

        if (firstFreeUdpPortInRange > 0)
        {
            Debug.Log($"..Open port found at {firstFreeUdpPortInRange}");
            return (ushort)firstFreeUdpPortInRange;
        }
        else
        {
            Debug.LogError($"..No valid UDP ports available in the given range ({startingPort} to {startingPort + maxNumberOfPortsToCheck})");
            return 0;
        }

    }
chanson
질문됨 2달 전20회 조회
1개 답변
0

Hey Chanson,

When a server process tries to acquire a port that has already been acquired by a second process I'm assuming it fails? If so, can the server backoff and retry to find the next port that is available? This might help deal with contention when multiple processes are detecting the same port as available.

Alternatively, you could pass in a static port number as a parameter to your ServerLaunchParameters. Since you have a fixed number of processes are going to launch, each could read a different unique parameter that it can use to as the port number it will try to acquire, completely avoiding contention.

Thanks!

답변함 2달 전
  • hey! thank you for the answer:

    When a server process tries to acquire a port that has already been acquired by a second process I'm assuming it fails? If so, can the server backoff and retry to find the next port that is available?

    Yes, this is exactly what happens when I test locally. The first process will start on port 5000, and the next on 5001, etc. However, this behavior is not carrying over to my GameLift instances.

    Alternatively, you could pass in a static port number as a parameter to your ServerLaunchParameters. Since you have a fixed number of processes are going to launch, each could read a different unique parameter that it can use to as the port number it will try to acquire, completely avoiding contention.

    Is this a best practice? If I only have 5 game sessions active, I wouldn't want 50 active processes, right?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인