Using AWS javascript SDK for gamelift

as advised and since there are no Javascript client SDK for gamelift, I used the AWS javascript SDK.
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/GameLift.html#constructor-property

However, i cannot seem to work it,
I have run the local test gamelift server for testing and I can communicate it using the aws CLI command like this
AWS gamelift describe-game-sessions --endpoint-url http://localhost:9080 --fleet-id fleet-123

However, when I attempt to connect from a standalone javascript file, i am getting
Network error if I set the endpoint to 9080 while connection to 5758 port I am getting CORS.
Is there any sample to connect to Gamelift server using AWS Javascript SDK?

here is my code

    <script src="https://cdnjs.cloudflare.com/ajax/libs/aws-sdk/2.1085.0/aws-sdk.js" integrity="sha512-P8mvO6DiBR/wJa/s5Z24/UimPqKZEHjTle0Z8Fb4cSPE+x7QDJu+E1QO/YO7BP8Ek19I2Y+C8xuCZCaBtZKmZA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

    <script>
        var gamelift = new AWS.GameLift(

            {endpoint : 'http://localhost:5758',

            accessKeyId :'abcde',

            secretAccessKey:'abcde',

            region:'us-west-2'});

        var params = {

            FleetId: 'fleet-123d',

        };

        gamelift.describeGameSessions(params, function(err, data) {

            if (err)

                console.log(err);

                //console.log(err, err.stack); // an error occurred

            else    

                console.log(data);           // successful response

        });

    </script>

Anyone can help?

Hi @Bond007

GameLift Server SDK and GameLift AWS SDK are different.

GameLift Server SDK is built into your server executable and deployed onto the EC2 instance, and is in charge of communicating with the GameLift daemon on the EC2 instance. Some APIs that Server SDK contains are initSDK, processReady, etc. (See full list)

GameLift AWS SDK is used to call GameLift services, with APIs such as CreateGameSession, StartMatchmaking, etc. (See full list)

The reason why you are getting network error is because there is no Gamelift AWS service deployed on your localhost.

There is no official support for Server SDK in javascript. However, if you want to code a GameLift game in Javascript, it’s recommended to use Realtime Servers, which allows you to setup a server by passing in a few Javascript files instead of a fully compiled C# or C++ project

Hi Thanks, Finally after days someone replied to my posts and i thought this forum is already dead.

I have a couple of followup questions,

The reason why you are getting network error is because there is no Gamelift AWS service deployed on your localhost.

You mean after i run the local gamelift server, and run the custom Gamelift server in unity, by pressing run, is that the “Gamelift AWS service deployed on your localhost” means?
Because I tried that, and the result is the same.
Or can you help me how to run/deploy a Gamelift AWS service in local instead?
We want to do all our development in local specialy the server part.

also as i mentioned above, changing the port to listen to 5758 (based on the GameliftLocal log for sdk) gives me the CORS error, which I cant change since its from the GameliftLocal server.

There is no official support for Server SDK in javascript. However, if you want to code a GameLift game in Javascript, it’s recommended to use Realtime Servers, which allows you to setup a server by passing in a few Javascript files instead of a fully compiled C# or C++ project

Im not building a server, im trying to have a browser based client access gamelift specialy sessions!

Hey @Bond007,

The GameLift AWS Service cannot be run locally. It runs in the cloud and you have to use standard AWS endpoints to call those APIs. This service is general and not used only by the game (which is why we use the AWS SDK to make calls).

GameLift Local is a way to simulate running your game on a remote machine (managed by GameLift) to test game server integration. In this case, your server-side code needs to use a GameLift Server SDK to communicate with the GameLift process and machine it is running on.

Im not building a server, im trying to have a browser based client access gamelift specialy sessions!

It seems like your use case fits RealTime servers, have you taken a look at our documentation which contains some examples on how to integrate your client? Integrating games with Amazon GameLift Realtime Servers - Amazon GameLift