Search Unity

Bug Lobby suddenly throws an exception after working for months.

Discussion in 'Lobby' started by ErezShahaf, Aug 22, 2022.

  1. ErezShahaf

    ErezShahaf

    Joined:
    Feb 3, 2022
    Posts:
    70
    Code (CSharp):
    1.      try
    2.         {
    3.             // Looking for a lobby
    4.  
    5.             // Add options to the matchmaking here (mode,rank,etc)
    6.             QuickJoinLobbyOptions options = new QuickJoinLobbyOptions();
    7.  
    8.             // Quick-join a random lobby
    9.             Lobby lobby = await Lobbies.Instance.QuickJoinLobbyAsync(options);
    Then in the catch I just open a new lobby becausethere isn't anything that's open.
    This has been working for a couple of months perfectly, but this week it started throwing an exception that stops the compiler even though it is inside a try catch.

    I am confident that I haven't changed anything in my code related to the lobbys.

    Code (CSharp):
    1. [Lobby]: NoOpenLobbies, (16006). Message: failed to find any open lobbies matching the search criteria
     
    Last edited: Aug 22, 2022
  2. veleek_unity

    veleek_unity

    Ben Randall Unity Technologies

    Joined:
    Aug 25, 2021
    Posts:
    59
    That's odd.

    What does the catch statement look like? That error should be a LobbyException which hasn't changed.
     
  3. ErezShahaf

    ErezShahaf

    Joined:
    Feb 3, 2022
    Posts:
    70
    Here it is:
    Code (CSharp):
    1. try
    2.         {
    3.             // Looking for a lobby
    4.  
    5.             // Add options to the matchmaking here (mode,rank,etc)
    6.             QuickJoinLobbyOptions options = new QuickJoinLobbyOptions();
    7.  
    8.             // Quick-join a random lobby
    9.             Lobby lobby = await Lobbies.Instance.QuickJoinLobbyAsync(options);
    10.             Debug.Log(message: "Joined lobby: " + lobby.Id);
    11.             statusString = "Match found";
    12.             Debug.Log(message: "Lobby Players: " + lobby.Players.Count);
    13.  
    14.             // Retreive the relay code of the lobby
    15.             string joinCode = lobby.Data["joinCode"].Value;
    16.             Debug.Log(message: "Received code: " + joinCode);
    17.             JoinAllocation allocation = await Relay.Instance.JoinAllocationAsync(joinCode);
    18.  
    19.             _joinData = new RelayJoinData
    20.             {
    21.                 Key = allocation.Key,
    22.                 Port = (ushort)allocation.RelayServer.Port,
    23.                 AllocationID = allocation.AllocationId,
    24.                 AllocationIdBytes = allocation.AllocationIdBytes,
    25.                 ConnectionData = allocation.ConnectionData,
    26.                 HostConnectionData = allocation.HostConnectionData,
    27.                 IPv4Address = allocation.RelayServer.IpV4
    28.             };
    29.             // Set transport data
    30.             NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(
    31.             _joinData.IPv4Address,
    32.             _joinData.Port,
    33.             _joinData.AllocationIdBytes,
    34.             _joinData.Key,
    35.             _joinData.ConnectionData,
    36.             _joinData.HostConnectionData
    37.             );
    38.             try
    39.             {
    40.                 statusString = "Joining match as client..";
    41.                 NetworkManager.Singleton.StartClient();
    42.             }
    43.             catch (Exception e)
    44.             {
    45.                 Console.WriteLine(e);
    46.                 statusString = e.ToString();
    47.                 throw;
    48.             }
    49.  
    50.         }
    51.         catch (LobbyServiceException e)
    52.         {
    53.             // If can't find a lobby with the set options - create one
    54.             Debug.Log(message: "Can't find a lobby... creating a new one");
    55.             statusString = "Can't find a lobby... creating a new one";
    56.             Debug.Log(e);
    57.             createMatch();
    58.         }
    After debugging and moving forward a couple of lines I can tell that after my catch triggers it gets inside WrappedLobbyService.cs 's catch and throws the error:
    Code (CSharp):
    1.         /// <inheritdoc/>
    2.         public async Task<Models.Lobby> QuickJoinLobbyAsync(QuickJoinLobbyOptions options = default)
    3.         {
    4.             try
    5.             {
    6.                 var quickJoinRequest = options == null ? null : new QuickJoinRequest(options.Filter, options.Player);
    7.                 var quickJoinLobbyRequest = new QuickJoinLobbyRequest(quickJoinRequest);
    8.                 var response = await TryCatchRequest(m_LobbyService.LobbyApi.QuickJoinLobbyAsync, quickJoinLobbyRequest);
    9.                 return response.Result;
    10.             }
    11.             catch (LobbyServiceException e)
    12.             {
    13.                 //JoinLobby conflict 409 handling (MPSSDK-92)
    14.                 if (e.Reason == LobbyExceptionReason.LobbyConflict)
    15.                 {
    16.                     var lobby = await LobbyConflictResolver(options?.Player, null, e);
    17.                     if (lobby != null)
    18.                     {
    19.                         return lobby;
    20.                     }
    21.                 }
    22.                 throw;
    23.             }
    I guess that there is a problem related to my credentials, but I am not running two builds
     
  4. ErezShahaf

    ErezShahaf

    Joined:
    Feb 3, 2022
    Posts:
    70
    I wanted to mention that if I press the unpause button in the editor after the error occurs the game will work with the lobby just fine. So I do not think that there's really an issue with credentials, it should be a bug.
     
  5. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    992
    I agree that no lobbies should be a debug log and not an exception error for people who use pause on error