Realtime server project setup

How do you setup a project for a realtime server, specifically for a more complex setup? When I try to compress multiple files it doesn’t work (never reports healthy and goes to error state) and the sample app (https://github.com/aws-samples/megafrograce-gamelift-realtime-servers-sample) only has 1 file. Currently it only runs for me with I compress 1 javascript file, I do this either using the zip command or right clicking and selecting compress (MacOS).

This script id (script-a248ef2f-927e-4c1f-a0a9-04c66f409094) is zipped up with a server.js file and the node_modules, it causes the fleet (fleet-c8645935-4702-4aff-9bc9-3e1948b09093) to crash when creating, here’s the events if that helps: https://gist.github.com/marchinram/98408d32729e89128813eb0a11d287e2

You should be able to include everything you want in your script’s zip including node_modules

Can you provide either a script_id or fleet_id + region and we can see whats wrong.

Make your root script name matches that of the launch path for the fleet and that you are uploading using the fileb settings ie:

-zip-file fileb://[*name of zip file*]

https://docs.aws.amazon.com/gamelift/latest/developerguide/realtime-script-uploading.html

Hi-

Sorry for the delay. I don’t see this script around anymore – did you delete it with delete-script?

At the moment the developer-provided script is loaded from a location external to the realtime server. As such, a node_modules in the developer zip is not in the resolution path. You can still use dependencies like this, but you’d have to copy them into the base directory.

e.g. instead of:

my-app.js
node_modules/my-dependency/.....

you’d have:

my-app.js
my-dependency/.....

Also, the recommended flow for troubleshooting startup issues with realtime servers is to start with a known-good script (for example the documentation-provided sample at

https://docs.aws.amazon.com/gamelift/latest/developerguide/realtime-script.html). Then your fleet should come up successfully. Then you can use update-script to update to your new version of the script. Logging into your fleet instance you can find logs at /local/game/logs/<process_id>/… – you should be able to get a clue as to what’s causing it to fail there.

Hope this helps!

Hey @BrianS-aws, thanks for the response! I tried this and am getting a FleetCapacityExceededException everytime i try to start a game session. The script id is now script-7340b487-f615-4cb4-94c0-a27c20f785a6 in us-east-2, can you check this?

A fleet capacity exception means that you were trying to place a game session but there were no free processes on your fleet to claim it. Check that your:

  • Fleet is scaled as you expect
    • You have the appropriate number of servers running per Gamelift instance
    • You have free processes (use the fleet metrics in the GameLift console to check this)
  • Your script is terminating GameSessions when the game completes.
    What I would expect is happening is that your are starting a GameSesion on a process but never finishing it. So all your processes are occupied by active GameSessions and all your capacity is consumed (metrics will quickly confirm this)

See the tickLoop example on the link below for an example of how GameSessions get cleaned up by your script. You can obviously do something different but for realtime you need to call ProcessEnding to terminate both the process and the active game session. GameLift will then quickly spin up a new free process ready for a new game session.

https://docs.aws.amazon.com/gamelift/latest/developerguide/realtime-script.html