Retrieving DNS Name and Port Before the onGameSessionStart Callback


I am currently writing a server using the C# SDK. I would ideally like to retrieve the DNS Name and Port of the process before calling ProcessReady(), as there is some initialization I would to do with that information. Is this possible? Am I misunderstanding a part of the process?

Thanks for the help!

asked 3 years ago201 views
2 Answers
Accepted Answer


Those are certainly possible.

For DNS name of the instance, you'd need to use EC2 metadata, see "HostName" in Here is how you can retrieve the data:

Port, on the other hand, is under your control. The recommendation is to pass them in via command line argument when executing your game server process, e.g.

aws gamelift create-fleet --region $REGION \
--name "TestFleet" --ec2-instance-type c5.large  \
--ec2-inbound-permissions FromPort=6252,ToPort=6254,IpRange="",Protocol=TCP FromPort=22,ToPort=22,IpRange="",Protocol=TCP \
--build-id $BUILD_ID \
--runtime-configuration ServerProcesses="[{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6251 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6252 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6253 gameSessionLengthSeconds:10',ConcurrentExecutions=1},\
{LaunchPath="/local/game/gamelift-test-app",Parameters='port:6254 gameSessionLengthSeconds:10',ConcurrentExecutions=1}]"

Then, in my gamelift-test-app, I retrieve the port parameter from the CLI and use that for ProcessReady.

answered 3 years ago

That is exactly what I was looking for. Thank you for the help!

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions