try
{
// Looking for a lobby
// Add options to the matchmaking here (mode,rank,etc)
QuickJoinLobbyOptions options = new QuickJoinLobbyOptions();
// Quick-join a random lobby
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.
[Lobby]: NoOpenLobbies, (16006). Message: failed to find any open lobbies matching the search criteria
That’s odd.
What does the catch statement look like? That error should be a LobbyException which hasn’t changed.
Here it is:
try
{
// Looking for a lobby
// Add options to the matchmaking here (mode,rank,etc)
QuickJoinLobbyOptions options = new QuickJoinLobbyOptions();
// Quick-join a random lobby
Lobby lobby = await Lobbies.Instance.QuickJoinLobbyAsync(options);
Debug.Log(message: "Joined lobby: " + lobby.Id);
statusString = "Match found";
Debug.Log(message: "Lobby Players: " + lobby.Players.Count);
// Retreive the relay code of the lobby
string joinCode = lobby.Data["joinCode"].Value;
Debug.Log(message: "Received code: " + joinCode);
JoinAllocation allocation = await Relay.Instance.JoinAllocationAsync(joinCode);
_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
);
try
{
statusString = "Joining match as client..";
NetworkManager.Singleton.StartClient();
}
catch (Exception e)
{
Console.WriteLine(e);
statusString = e.ToString();
throw;
}
}
catch (LobbyServiceException e)
{
// If can't find a lobby with the set options - create one
Debug.Log(message: "Can't find a lobby... creating a new one");
statusString = "Can't find a lobby... creating a new one";
Debug.Log(e);
createMatch();
}
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:
/// <inheritdoc/>
public async Task<Models.Lobby> QuickJoinLobbyAsync(QuickJoinLobbyOptions options = default)
{
try
{
var quickJoinRequest = options == null ? null : new QuickJoinRequest(options.Filter, options.Player);
var quickJoinLobbyRequest = new QuickJoinLobbyRequest(quickJoinRequest);
var response = await TryCatchRequest(m_LobbyService.LobbyApi.QuickJoinLobbyAsync, quickJoinLobbyRequest);
return response.Result;
}
catch (LobbyServiceException e)
{
//JoinLobby conflict 409 handling (MPSSDK-92)
if (e.Reason == LobbyExceptionReason.LobbyConflict)
{
var lobby = await LobbyConflictResolver(options?.Player, null, e);
if (lobby != null)
{
return lobby;
}
}
throw;
}
I guess that there is a problem related to my credentials, but I am not running two builds
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.
I agree that no lobbies should be a debug log and not an exception error for people who use pause on error