I'm working on getting a GameLift fleet up and running. I've been testing in GameLift Local for a while now and just recently started using GameLift proper to test the server build. I have it set to be able to handle 10 concurrent processes per instance (with ten ports specified for use), and I only have one instance running. I can connect to the instance just fine with one client, but I cannot connect with additional clients, even though I set it to allow up to ten. Checking the GameSessions tab for the Fleet in the GameLift console, I can see that only one GameSession is ever active at a time.
I'm also seeing a bunch of SERVER_PROCESS_CRASHED events in the event tab that say "Server process exited without calling ProcessEnding(), exitCode(0)," and these are happening between every 5 to 10 minutes.
I'm assuming the two issues are connected but I'm not sure how to fix it. I've looked for solutions but I haven't found anything that works yet. The game server is built in Unity, and there's a couple of parts of the code that I'm curious might be the issue, even though I never saw any such errors in GameLift local.
First, I wonder if I'm calling Application.Quit() to quickly after calling ProcessEnding(). Right now I have them running like this:
var result = GameLiftServerAPI.ProcessEnding();
_networkManager.ServerManager.StopConnection(true);
Application.Quit();
Based on some other posts I've seen, it sounds like I need to wait until the ProcessEnding() result is true, but shouldn't it already wait to get the result in this context before calling Application.Quit()?
Second, I thought it's possible that my method for setting the port might be causing an issue. I had seen a post that said it wasn't working on Linux at one point, but I tested it on a regular Linux EC2 instance in a dummy project with multiple processes running, and they were able to increment through the array of ports I set looking for unused ports. That code is like this:
private void SelectAvailablePort()
{
foreach (var port in ports)
{
bool available = false;
available = IsListeningPortAvailable(port);
if (available)
{
sessionPort = port;
break;
}
}
}
public bool IsListeningPortAvailable(int port) =>
!IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners().Any(x => x.Port == port);
I'm not sure if this is breaking something on the server, since I was able to get it to work fine in the dummy project on a Linux instance, but since I cannot get past the single GameSession and I remember seeing someone saying it didn't work on Linux, it makes me wonder if it could be the issue.
Do you see anything in the code above that could be causing the issue, or if not, is there something else I should try checking to see if it's the source of the problem. Again, I'm just trying to get the game to allow for multiple GameSessions per instance, but only one server process is active at a time. When I try to connect from a second client, I get an error that says there weren't any server processes available. Any advice you may have would be greatly appreciated!