NoOpenLobbies Found after restarting game.

So i have made this server/client system where we start server on a computer and then my Quest 2 is connected as client. I am using Relay to connect over regions. The app can connect to host/server for first time, but after closing and playing again throws this error. To solve this I have to restart server (close and restart the application) which I don’t want, I want player to connect anytime to this lobby. I have searched through multiple forums but not able to find solution so starting new thread.

Hi @Jeel_Patel , I’d recommend to open a ticket through the Unity Dashboard. You’ll easily get a direct reply from the lobby team there

@Jeel_Patel - When you close the app and play again, is the client explicitly removing themselves from the Lobby. If you don’t do that, the Lobby service has no way of automatically detecting that your game client has disconnected, so the player is probably still in the Lobby. Then when you start up the app again, it’s unable to find any available lobbies to Join because you’re already a member in the only lobby that’s available.

You can use the Get Joined Lobbies API to see if you’re already connected to any lobbies and either disconnect (so you can connect to a new one) or just use that lobby info and pretend that you never left.

Thank you @veleek_unity , seems like i got past to that error, however now i am facing this HttpException. Im anot able to debug as its not coming through my code. I would need further help!

Based on the error, it looks like you’re using a Relay Join Code that the Relay service doesn’t know about. Lobby Join Code is not the same as Relay Join Code. Are you using the Lobby Join Code to connect to a Relay?

You must have a client create a Relay (often the host of the lobby, but not required) and then have them share that information with the rest of the lobby members so they can connect themselves: Relay integration.

public async void JoinAdminLobby()
    {
        Debug.Log("Looking for admin lobby...");
        try
        {
            // Looking for a lobby

            // Add options to the matchmaking (mode, rank, etc..)
            QuickJoinLobbyOptions options = new QuickJoinLobbyOptions();

            // Quick-join a random lobby
            lobby = await LobbyService.Instance.QuickJoinLobbyAsync(options);

            connectedClients = lobby.Players.Count;
            Debug.Log("Joined Admin lobby: " + lobby.Name);
            Debug.Log("Lobby Players: " + lobby.Players.Count);

            // Retrieve the Relay code previously set in the create match
            string joinCode = lobby.Data["joinCode"].Value;

            Debug.Log("Received code: " + joinCode);

            JoinAllocation allocation = await Relay.Instance.JoinAllocationAsync(joinCode);

            Debug.Log("CODE: Relay allocation finished");

            // Create Object
            joinData = new RelayJoinData
            {
                Key = allocation.Key,
                Port = (ushort)allocation.RelayServer.Port,
                AllocationID = allocation.AllocationId,
                AllocationIDBytes = allocation.AllocationIdBytes,
                ConnectionData = allocation.ConnectionData,
                HostConnectionData = allocation.HostConnectionData,
                IPv4Address = allocation.RelayServer.IpV4
            };

            string relayJoinCode = await Relay.Instance.GetJoinCodeAsync(allocation.AllocationId);
            PlayerPrefs.SetString("RelayJoinCode", relayJoinCode);

            // Set transport data
            NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(
                joinData.IPv4Address,
                joinData.Port,
                joinData.AllocationIDBytes,
                joinData.Key,
                joinData.ConnectionData,
                joinData.HostConnectionData);

            // Finally start the client
            Debug.Log("CODE: Relay DateSetting finished");
            NetworkManager.Singleton.StartClient();

            //Spawn network player
            //SpawnPlayer();     //Wait for login scene to spawn on successful login

            // Trigger events Here
            isConnectedToLobby = true;

            //FindObjectOfType<NetworkAdmin>().SpawnPlayerServerRpc();
            Debug.Log("CODE: Joining Finished");

        }
        catch (LobbyServiceException e)
        {
            // If we don't find any lobby

            Debug.Log("Cannot find admin lobby: " + e + ",Retrying");

            var lobbyIds = await LobbyService.Instance.GetJoinedLobbiesAsync();
            Debug.Log("Current lobbies are : " + lobbyIds.ToArray().Length);
            if (lobbyIds.ToArray().Length > 0)
            {
                Debug.Log("Player is in lobby: " + lobbyIds.ToArray()[0]);
                StartCoroutine(RetryJoinLobby(lobbyIds.ToArray()[0]));
            }
            /*
            if (lobbyIds.ToArray().Length > 0)
            {
                JoinExistingLobby(lobbyIds.ToArray()[0]);
            }
            else
            {
                StartCoroutine(RetryJoinLobby(lobbyIds.ToArray()[0]));
            }
            */
        }
    }

async void JoinExistingLobby(string lobbyId)
    {
        //JoinAdminLobby();
        try
        {
            // Looking for a lobby

            // Add options to the matchmaking (mode, rank, etc..)
            QuickJoinLobbyOptions options = new QuickJoinLobbyOptions();

            // Quick-join a random lobby
            lobby = await LobbyService.Instance.ReconnectToLobbyAsync(lobbyId);
            //lobby = await LobbyService.Instance.QuickJoinLobbyAsync(options);

            connectedClients = lobby.Players.Count;
            Debug.Log("Joined Admin lobby: " + lobby.Name);
            Debug.Log("Lobby Players: " + lobby.Players.Count);

            // Retrieve the Relay code previously set in the create match
            string joinCode = lobby.Data["joinCode"].Value;

            Debug.Log("Received code: " + joinCode);

            JoinAllocation allocation = await Relay.Instance.JoinAllocationAsync(joinCode);

            Debug.Log("CODE: Relay allocation finished");

            // Create Object
            joinData = new RelayJoinData
            {
                Key = allocation.Key,
                Port = (ushort)allocation.RelayServer.Port,
                AllocationID = allocation.AllocationId,
                AllocationIDBytes = allocation.AllocationIdBytes,
                ConnectionData = allocation.ConnectionData,
                HostConnectionData = allocation.HostConnectionData,
                IPv4Address = allocation.RelayServer.IpV4
            };
            // Set transport data
            NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(
                joinData.IPv4Address,
                joinData.Port,
                joinData.AllocationIDBytes,
                joinData.Key,
                joinData.ConnectionData,
                joinData.HostConnectionData);

            // Finally start the client
            Debug.Log("CODE: Relay DateSetting finished");
            NetworkManager.Singleton.StartClient();

            //Spawn network player
            //SpawnPlayer();
            //Wait for login scene to spawn on successful login

            // Trigger events Here
            isConnectedToLobby = true;

            //FindObjectOfType<NetworkAdmin>().SpawnPlayerServerRpc();
            Debug.Log("CODE: Joining Finished");

        }
        catch (LobbyServiceException e)
        {
            // If we don't find any lobby
            Debug.LogError("Cannot find admin lobby: " + e + ",Retrying in 5 seconds");
            StartCoroutine(RetryJoinLobby(lobbyId));
        }
    }

@veleek_unity SO on first load, its able to find and connect to lobby (here on line 24, im using retrieve code) but in JoinExistingLobby() im getting the error, seems like you’re right, but how come it is working on JoinAdminLobby() ? but not in JoinExistingLobby()?
Could you tell me how to do get relay join code in JoinExistingLobby() ?

Okay, i found a work around, but not sure it its ideal or not.
So whenever i restart my application for reconnection, its finding 2 lobbies (don’t know why?). So it didn’t work before because i was getting code for first lobby found. Now if i query code for last lobby found and use that code to reconnect lobby through relay, its working!!.
Curious to know if its a bug, or its how its supposed to be?