Cant seem to make multiple Game session with diffrent Port

I have made a system to check available port that is not used, but i cant seem to make the gamesession use diffrent port from the previous one, any help i can get?

I assume you are running multiple servers per instance. Each server should report in its ProcessReady call which port its listening on. This port send back here is then the port for each game session assigned to that server process.

So it sounds like instead of setting the server port via a game parameter in the run time configuration part of create-fleet, your servers are dynamically finding an open port in a given port range and using that?

In which case make sure you are setting the port as part of the ProcessParameters section of your ProcessReady call.

1 Like

hello pip sorry for the late reply i havent try it yet, but i have a quaestion does when we make there is 10 concurrent process, is there 10 server.exe on standby or each server.exe will be up only when it is needed

GameLift will launch x copies of your server per instance based on your launch configuration. If you need more servers then it will scale up a new instance and launch x copies of your server etc.

That way your servers are always ready to host new game sessions.

You can control who many new game sessions get placed at anytime via MaxConcurrentGameSessionActivations to reduce peak load on your instance.

See https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-multiprocess.html

does that mean processready() will only be called on the time i make a new game session?or will it be called when these 10 server is up?

Hello pip i have try it but doesnt seem to amount any success, can u maybe point out anything wrong with my code ?

Code looks ok, but I can’t see how you are setting _port, thats the important part.

As for your earlier question, GameLift is going to launch 10 (if thats how many you’ve asked for) server processes roughly at the same time once the EC2 instance is ready.

Server process launch is async so they may not all launch exactly at the same time but they will be started close together. So you need to account for that if you are doing dynamic port allocation (ie randomly grab a port in your server range, see if its available for use, try another port until success.)

I would while troubleshooting, limit your servers to a few (ie 2-3) and prefer static port allocation via passed parameters from your runtime launch configuration. Once you’ve got a fleet working that way, its easier to make changes to get to your desired instance count/port allocation mechanism.

Hello pip sorry from the late reply here is the snippet for setting the port

If there is a part that is wrong, it would be helpful to get some help/ pointing to the right direction

helllo pip i still cant seem to get it working any help?

@Vincen_kaiuman - really sorry that you are still having trouble here.

Things I would try:

  • If you are not, log the ports you pick per server and send in the ProcessReady parameters - ensure that your server processes are actually running on different ports. If not things will break.
  • simplify the problem and statically assign the ports via the runtime configuration. Ensure things are working outside of the dynamic port allocation model ie
ServerProcesses=[{LaunchPath='C:\game\MyGame.exe',Parameters=port 33435,ConcurrentExecutions=1},{LaunchPath='C:\game\MyGame.exe',Parameters=port 33436,ConcurrentExecutions=1}]"

Theres lots of ways of doing this sort of thing but you need to make it work for multiple executables launching roughly at the same time so you probably need to bind a socket / httplistener etc to the port to claim, or back off and try another port etc.