Label bug?

Hi,

I have a very rare and strange bug.

Sometimes (I’d say 1 times out of 20) the values in the the match label interface will be inverted which prevent matchmaking to happen.

If my match label is like this :

interface MatchLabel {
    matchBet: number,
    playerLevel:number
    }

it will very rarely (1 time out of 20 or even more) be transformed like this :

interface MatchLabel {
    playerLevel:number,
    matchBet: number
   
    }

I can see the change in the web console.


Capture d’écran 2022-03-02 à 17.02.42

It prevents a matchmaking to happen despite all the conditions met in the match label.

Any ideas what might cause this ?

A JSON encoded label doesn’t guarantee the ordering of the key/value pairs, can you please post the query you’re using to join matchmaking?

The function in Unity :

  public class MatchBet
    {
        public int matchBet;
        public int playerLevel;
    }

private async void FindPairImpairPvPMatch()
    {
        MatchBet playerBetToServer = new MatchBet();
        playerBetToServer.matchBet = playerRekiumsBet;
        playerBetToServer.playerLevel = playerLevel;


        
        string jsonFromClient = JsonUtility.ToJson(playerBetToServer);
        Debug.Log(jsonFromClient);
        var payload = jsonFromClient;
        var rpcid = "find_match_pairimpair";

        var serverResponse = await client.RpcAsync(session, rpcid, payload);

        var serverResponsePayload = serverResponse.Payload;

        

        MatchIDsFound serverResponseMatchId = JsonUtility.FromJson<MatchIDsFound>(serverResponsePayload);

        matchIDs = serverResponseMatchId.matchIds;

       

        //Temp Debug to see the match id
        matchIdTemp.text = serverResponseMatchId.matchIds[0];

        matchID=serverResponseMatchId.matchIds[0];

        matchVsBot = false;
        PairImpairPvPJoinMatch(); 
 }

On the server :

//MatchLabel is in the module representing the game.
interface MatchLabel {
    matchBet: number,
    playerLevel:number
    
}

//This function is in its own module match_rpc.ts

let rpcFindMatchPairImpair: nkruntime.RpcFunction = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, payload: string): string {
    if (!ctx.userId) {
        throw Error('No user ID in context');
    }

    if (!payload) {
        throw Error('Expects payload.');
    }

   

    let matches: nkruntime.Match[];
    try {
        
        logger.debug(ctx.userId , "Has submited the following label :", payload);
        
       

        matches = nk.matchList(10, true, payload, null, 1, null);
        
        
    } catch (error) {
        logger.error('Error listing matches: %v', error);
        throw error;
    }

    let matchIds: string[] = [];
    if (matches.length > 0) {
        // There are one or more ongoing matches the user could join.
        matchIds = matches.map(m => m.matchId);
        logger.error('Another user could join a match, we need to send him back a matchid');
        
    } else {
        // No available matches found, create a new one.
        try {
            matchIds.push(nk.matchCreate(moduleNamePairImpairPvP));
            
            
            logger.error('We have created a Pair Impair PvP match following a user request');
            
            
        } catch (error) {
            logger.error('Error creating match: %v', error);
            throw error;
        }
    }

    let res: RpcFindMatchResponse = { matchIds };
    return JSON.stringify(res);
    
}

The label field of matchList will apply an exact match which doesn’t quite work for json encoded labels, what you want to do is use the query param and use the query syntax - see Server authoritative multiplayer - Heroic Labs Documentation.