Sign In Register

How can we help you today?

Start a new topic

HTTP POST Request sometimes fails?

Hey there,


I already created a ticket on GameLift end, but I wanted to check here too, just to be sure.

My code to communicate with GameLift works in 3 of 4 Projects.
I compared the code and it's the same. I check the credentials of GameLift and they are fine.

My issue is, that if I create a call A and then a call B in the Response of call A, suddenly GameLift doesn't answer the call anymore.

I made sure that call B is not broken by calling it directly and that works.

I can't seem to figure out why this happens.

"message: Error performing POST for the URL https://gamelift.us-east-1.amazonaws.com/:gamelift.us-east-1.amazonaws.com:443 failed to respond\"


It's quite annoying ):


Any idea would be helpful.

Kind regards,
Cedric Neukirchen


1 person has this question

 Hi Cedric, is call B in the Cloud Code of the response or on the client?


Cheers,

Omar

Hey Omar,


both calls are in Cloud Code. 

All of my Requests to GameLift use a "GL_Request" module, that does all the Signature stuff.

The calls themselves look like this:

 

/**
*   Requests the state of the specified GameSession.
*/

require('GL_Request');

function GL_GameSessionStateRequest(GameSessionID, CallbackFunction)
{
    var creds = { key: '##################', secret: '#################################'};
    var target = 'GameLift.DescribeGameSessionDetails';
    var requestBody = '{"GameSessionId":"' + GameSessionID + '"}';
    

    var Request = new AWSRequest(
        'gamelift.us-east-1.amazonaws.com',             // Endpoint
        '/',                                            // CanonicalURI
        {                                               // Query
        }
        ,
        [                                               // Headers
            {
                name : 'X-Amz-Target',
                value : target
            },
            {
                name: 'Content-Type',
                value: 'application/x-amz-json-1.1'
            }
        ],
        requestBody,                                    // Request Payload
        "us-east-1",                                    // Region
        "gamelift",                                     // Service
        creds                                           // Credentials
    );    

    Request.makeRequest(CallbackFunction);
}

 

In the Global "MatchFound" Message, I do this:

 

function OnCreateGameSessionResponse(result, error)
{
    if(result != null)
    {
        Spark.getLog().debug("Result Code: " + result.statusCode);
        Spark.getLog().debug("Result Headers: " + JSON.stringify(result.headers));
        Spark.getLog().debug("Result Data: " + JSON.stringify(result.data));
        
        // "200" means everything is good
        if(result.statusCode == 200)
        {
            var GameSessionID = result.data.GameSession.GameSessionId;
            GL_GameSessionStateRequest(GameSessionID, OnRequestGameSessionStateResponse);
        }
    }
    else if(error != null)
    {
        Spark.getLog().debug("Error Code: " + error.statusCode);
        Spark.getLog().debug("Error Headers: " + JSON.stringify(error.headers));
        Spark.getLog().debug("Error Data: " + JSON.stringify(error.data));
    }
}

GL_CreateGameSessionRequest(10, "alias-b9cb3135-7390-4fd4-af76-622ece965ebc", OnCreateGameSessionResponse);

 


The Response function for the second call looks similar, so I leave that away.

It all worked a few weeks ago in all other projects I used it in. Now it seems to fail with aboves Error.
I can call the "Call B" alone, without calling "Call A" before it, and it works.

So it only fails if I call them right after each other. It's also not about Call A or Call B. If I swap the order, Call A fails.

I assume it is on GameLift's end, but I just wanted to make sure that it's not a cause of recent changes to your HTTP Class or so.

Kind regards,
Cedric Neukirchen

 Hi Cedric,


Is there any information you can give us about the error? Maybe Gamelift can provide that? That way we can follow it up from our side.


Cheers,

Omar

I would love to. GameLift hasn't answered yes, but then again there was a weekend.

You can follow it here: https://gamedev.amazon.com/forums/questions/60652/gameliftus-east-1amazonawscom443-failed-to-respond.html

I will post here once I know more.

Kind regards,
Cedric Neukirchen

Hey there,

so a small update. GameLift says that not reaching the Server is because of a wrong Endpoint.

Now I've been using the same system for the past months and I haven't changed anything of the request code.

In fact, each request on their own works.

GameLift says that this URL is invalid:

https://gamelift.us-east-1.amazonaws.com/:gamelift.us-east-1.amazonaws.com:443

Because of the : after the /

https://gamelift.us-east-1.amazonaws.com/   :    gamelift.us-east-1.amazonaws.com:443

Now since each single Request works and only the one after the first one fails, I assume it must really be part of the way your HTTP Request class works. I will look into my code again, if I, by any chance, put a : in there, but I kinda doubt that, because then it wouldn't fail for every second+ call, but actually every call.

Could you maybe look into recent changes of your HTTP class and see if something might happen if someone tries to perform 2 calls right after each other?

In addition, this is the POST URL I use, right before making the request.
This one failed.

It's always contructed from ground up:

"PostURL: https://gamelift.us-east-1.amazonaws.com/ | Headers: {"X-Amz-Target":"GameLift.DescribeGameSessionDetails","Content-Type":"application/x-amz-json-1.1","X-Amz-Date":"20170904T103354Z","host":"gamelift.us-east-1.amazonaws.com","Authorization":"AWS4-HMAC-SHA256 Credential=###################/20170904/us-east-1/gamelift/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=d4226b90bb29ba555ca16bbc0d028f1fa3e0fd099c2e9313e223bcc372c04b68"} | Payload: {"GameSessionId":"arn:aws:gamelift:us-east-1::gamesession/fleet-f4dab7eb-0ded-4366-b57d-1a307a498d3b/gsess-65d0a4a0-0969-4a28-a941-013cc1ecc8c6"}"

Replaced the credentials for this post with ###.

As you can see, the URL is not with a ":" here.

Here is one that worked:

"PostURL: https://gamelift.us-east-1.amazonaws.com/ | Headers: {"X-Amz-Target":"GameLift.CreateGameSession","Content-Type":"application/x-amz-json-1.1","X-Amz-Date":"20170904T103354Z","host":"gamelift.us-east-1.amazonaws.com","Authorization":"AWS4-HMAC-SHA256 Credential=###################/20170904/us-east-1/gamelift/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=159831a791ffb6cb59286583c3608330799787cc545b502d6ca5496d3e539621"} | Payload: {"MaximumPlayerSessionCount": 10, "AliasId": "alias-b9cb3135-7390-4fd4-af76-622ece965ebc"}"

And yes, if I do the CreateSession after the DescribeSession, it fails the same way.
So it's not the DescribeSession call.

 I've promoted this to Ticket #6215


We'll track it there better. Can you fill in your Game API and any other details please?


Cheers,

Omar

Yus, did. Should I post my latest answers into the ticket as well or is that somehow linked to this post?

Ahhh I have this issue too!! I thought I was going crazy!


Error performing POST form for the URL https://partner.steam-api.com/ISteamMicroTxnSandbox/InitTxn/v3/:partner.steam-api.com:443 failed to respond


What's up with that ":" in there?


1 person likes this

I'm actually having the same issue here:


{"message":"Error performing POST for the URL https://partner.steam-api.com/ISteamMicroTxn/InitTxn/v3/:partner.steam-api.com:443 failed to respond"}


Did you guys found out the reason?

I ended up offsetting the requests via a short delay.

Hi Cedric, many thanks for the reply. Could you please elaborate (or give a small example) how did you do that? 

Well, I issued the first POST Request and in the response of that I used the Scheduler to delay the second Post request.

 

var Timer = Spark.getScheduler();
Timer.inSeconds("GL_RequestGameSessionState", 3, {"MatchID" : MatchID});

 It's been a while and I can't fully recall (nor am I allowed to share) all of the underlying code.
But that piece up there basically fixed it.

Oh I see, I didn't understand what you meant by offsetting the request. I understand now, it's a bit weird that we have to delay these kind of requests (especially on our case, when the requests that are failing are the ones to purchase an in-game product). Do they (gamesparks) give you a reason why we should do that this way or did you come up with the solution by yourself? Sorry for asking so many reasons, and again thank you so much for replying!

Login to post a comment