question

davidruiz avatar image
davidruiz asked

Server/RedeemMatchmakerTicket working on Unity Editor, not in Android device

Hi,

I'm trying to make a matchmaking system and when I get to the point to validate the ticket retrieved from Client.Matchmake I try to validate it calling ExecuteCloudScript which executes a "redeemMatchmakerTicket" function in my cloudscript. Here's the cloudscript code:

handlers.redeemMatchmakerTicket = function(args, context) {
	log.info("LobbyId received: " + args.LobbyId);
	log.info("Ticket received: " + args.Ticket);
	
	var redeemMatchmakerTicketResult = server.RedeemMatchmakerTicket({
		LobbyId : args.LobbyId,
		Ticket : args.Ticket
	});
		
	return redeemMatchmakerTicketResult;
};

And this is my C# code to call this cloudscript function:

private void RedeemMatchmakerTicket(string lobbyId, string ticket)
    {
        Debug.Log(ticket);
        PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest()
        {
            FunctionName = "redeemMatchmakerTicket",
            GeneratePlayStreamEvent = true,
            FunctionParameter = new
            {
                Ticket = ticket,
                LobbyId = lobbyId
            }
        }, OnTicketRedeemed, HandlePlayFabError);
    }

I get the lobbyId and the ticket from the Matchmake call.

Now, this works perfectly in the editor, here's a screen of the console log:

And when I build and try on an Android device, this occurs:

This is the error log in my Dashboard PlayStream:

{
    "EventName": "player_executed_cloudscript",
    "Source": "CloudScript",
    "FunctionName": "redeemMatchmakerTicket",
    "CloudScriptExecutionResult": {
        "FunctionName": "redeemMatchmakerTicket",
        "Revision": 17,
        "FunctionResult": null,
        "FunctionResultTooLarge": null,
        "Logs": [
            {
                "Level": "Info",
                "Message": "LobbyId received: 10708125309171672530",
                "Data": null
            },
            {
                "Level": "Info",
                "Message": "Ticket received: undefined",
                "Data": null
            },
            {
                "Level": "Error",
                "Message": "PlayFab API request error",
                "Data": {
                    "api": "/Server/RedeemMatchmakerTicket",
                    "request": {
                        "LobbyId": "10708125309171672530"
                    },
                    "result": null,
                    "apiError": {
                        "code": 400,
                        "status": "BadRequest",
                        "error": "InvalidParams",
                        "errorCode": 1000,
                        "errorMessage": "Invalid input parameters",
                        "errorHash": null,
                        "errorDetails": {
                            "Ticket": [
                                "The Ticket field is required."
                            ]
                        }
                    }
                }
            }
        ],
        "LogsTooLarge": null,
        "ExecutionTimeSeconds": 0.12422559999999999,
        "ProcessorTimeSeconds": 0.016,
        "MemoryConsumedBytes": 57960,
        "APIRequestsIssued": 1,
        "HttpRequestsIssued": 0,
        "Error": {
            "Error": "CloudScriptAPIRequestError",
            "Message": "The script called a PlayFab API, which returned an error. See the Error logs for details.",
            "StackTrace": "Error\n    at handlers.redeemMatchmakerTicket (99-main.js:27:44)"
        }
    },
    "EventNamespace": "com.playfab",
    "EntityType": "player",
    "TitleId": "99",
    "EventId": "98cba57ed6264e6d94d460683f2e34d9",
    "EntityId": "F354F89420254BA2",
    "SourceType": "BackEnd",
    "Timestamp": "2018-02-20T07:09:06.2293408Z",
    "History": null,
    "CustomTags": null,
    "Reserved": null
},
{
    "EventName": "player_executed_cloudscript",
    "Source": "CloudScript",
    "FunctionName": "deregisterGame",
    "CloudScriptExecutionResult": {
        "FunctionName": "deregisterGame",
        "Revision": 17,
        "FunctionResult": {
            "Message": {}
        },
        "FunctionResultTooLarge": null,
        "Logs": [
            {
                "Level": "Info",
                "Message": "LobbyId received: 10708125309171672530",
                "Data": null
            }
        ],
        "LogsTooLarge": null,
        "ExecutionTimeSeconds": 0.0871358,
        "ProcessorTimeSeconds": 0.016,
        "MemoryConsumedBytes": 28488,
        "APIRequestsIssued": 1,
        "HttpRequestsIssued": 0,
        "Error": null
    },
    "EventNamespace": "com.playfab",
    "EntityType": "player",
    "TitleId": "99",
    "EventId": "68d143d578f24b01b36203abd7f1b6d2",
    "EntityId": "F354F89420254BA2",
    "SourceType": "BackEnd",
    "Timestamp": "2018-02-20T07:09:06.7038029Z",
    "History": null,
    "CustomTags": null,
    "Reserved": null
}

So clearly there's something wrong when I try to send the ticket to the back-end. But just before I make the ExecuteCloudScript call I log the value and it's fine.

Any ideas? Thank you for your time.

apisunity3dCloudScript
editorlog.png (11.8 KiB)
logcat.png (24.9 KiB)
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Can you describe in more detail what you're trying to create, exactly? RedeemMatchmakerTicket is for use with custom game servers (https://api.playfab.com/docs/tutorials/landing-tournaments/custom-game-servers), not Cloud Script.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

davidruiz avatar image davidruiz commented ·

Nevermind, I forgot I'm using an obfuscator when building, so it messed up the API calls. I disabled it and now it's working correctly. I'll try to tweak the Obfuscator to prevent it from messing up these calls.

What I'm trying to do is register my Photon's games with the Playfab Matchmaker in order to monitor them and be able to get the list of games that are interesting for a specific user (for instance a statistic-based matchmaking, Facebook friend games, etc) before even connecting to Photon.

Thank you!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.