Query for created lobbies does not find any lobbys

Hello,

I´m new to Unity Multiplayer section and trying to create a simple multiplayer game while using Unity Lobby. I´ve managed to create a lobby and join it with another instance of my application using the provided join code. Now when I try to query for existing lobbys to show them to the user as options no matter what I try to do the query yields 0 results. Is there anything I might be missing ?

Here is how I create my lobby:

    public static async Task CreateLobby(LobbyConfig config)
    {
        transport = Object.FindObjectOfType<UnityTransport>();
        var alloc = await RelayService.Instance.CreateAllocationAsync(config.maxPlayerAmount);
        var joinCode = await RelayService.Instance.GetJoinCodeAsync(alloc.AllocationId);

        var lobbyOptions = new CreateLobbyOptions
        {
            Data = new Dictionary<string, DataObject>
            {
                { Constants.JoinCode, new DataObject(DataObject.VisibilityOptions.Member,joinCode)},
                { Constants.LobbyName, new DataObject(DataObject.VisibilityOptions.Public,config.lobbyName)}
            }
        };

        lobbyOptions.IsPrivate = false;
        currentLobby = await Lobbies.Instance.CreateLobbyAsync(config.lobbyName,config.maxPlayerAmount,lobbyOptions);

        transport.SetHostRelayData(alloc.RelayServer.IpV4, (ushort)alloc.RelayServer.Port,alloc.AllocationIdBytes,alloc.Key,alloc.ConnectionData);
        Debug.Log("Lobbyname: " + currentLobby.Name);
        Debug.Log("LobbyCode: " + currentLobby.LobbyCode);
        Debug.Log("Private: "+ currentLobby.IsPrivate);
        Debug.Log("Slots: " + (currentLobby.MaxPlayers - currentLobby.AvailableSlots)+"/" + currentLobby.MaxPlayers);
        PingCurrentLobby(); //Heartbeat
        RefreshLobby();
    }

and here how I try to find it:

    public static async Task<List<Lobby>> SearchLobbies()
    {
        var foundLobbies = await Lobbies.Instance.QueryLobbiesAsync();
        Debug.Log("LobbyCount: " + foundLobbies.Results.Count);

        return foundLobbies.Results;
    }

Thanks in advance!

Just want to clarify your heartbeat code and how that affects queries.
I see you have a method PingCurrentLobby(); //Heartbeat
Does that continually heartbeat the lobby or just do it once?

The lobby must receive a heartbeat at least every 30 seconds or it will not show up in queries/quick joins.
The query code to find it should be fine, off the top of my head, the only reasons the search code could fail are:

  • the lobby became stale (no host heartbeat in 30 seconds)

  • The other client/editor is not configured to look at the exact same project Ids?

  • Something running after CreateLobby(LobbyConfig config) executs is deleting the lobby.

Thanks for the answer, I revisited my heartbeat-function and yes there was an error which caused it to not repeat the heartbeat. Now I can find my lobbys.

Thanks for the help