Unity version: 2022.3.13f1
Lobby version: 1.1.2 (I know there is an 1.2 update, but for some reason it doens’t show on my package manager)
On my code I am just subscribing to lobby callbacks and my HandlePlayerJoined calls an action so I can listen to it anywhere
private async void SubscribeToLobbyEvents()
{
Debug.Log("Subscribing to lobby events");
LobbyEventCallbacks eventCallbacks = new();
eventCallbacks.PlayerLeft += HandlePlayerLeft;
eventCallbacks.PlayerJoined += HandlePlayerJoined;
eventCallbacks.PlayerDataChanged += HandlePlayerDataChanged;
eventCallbacks.KickedFromLobby += HandleKickedFromLobby;
eventCallbacks.LobbyChanged += HandleLobbyChanged;
_LobbyEvents = await LobbyManager.Instance.LobbyHelper.SubscribeToLobbyEventsAsync(Id, eventCallbacks);
}
private void HandlePlayerJoined(List<LobbyPlayerJoined> list)
{
foreach (LobbyPlayerJoined player in list)
{
LocalPlayer localPlayer = new();
localPlayer.FromLobbyPlayerObj(player.Player);
Players.Add(localPlayer);
OnPlayerJoined?.Invoke(localPlayer);
}
}
everything works fine 99% of the time, but for some reason sometimes a rate limit get lobby error is raised from no where then HandlePlayerJoined isn’t called, even through I am not polling for updates and I’m not calling the GetLobbyAsync method anywhere, so it seems to be from the subscription.
Everything that happens after HandlePlayerJoined is called is really simple so I don’t think there is any problem on my code, I don’t know how to reproduce this error as it is quite rare and I haven’t figured what causes it.
This is the full error message:
[Lobby]: Unity.Services.Lobbies.LobbyServiceException: Rate limit has been exceeded ---> Unity.Services.Lobbies.Http.HttpException`1[Unity.Services.Lobbies.Models.ErrorStatus]: (429) HTTP/1.1 429 Too Many Requests
at Unity.Services.Lobbies.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.Lobbies.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) [0x0007b] in .\Library\PackageCache\com.unity.services.lobby@1.1.2\Runtime\Http\ResponseHandler.cs:114
at Unity.Services.Lobbies.Http.ResponseHandler.HandleAsyncResponse[T] (Unity.Services.Lobbies.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) [0x00001] in .\Library\PackageCache\com.unity.services.lobby@1.1.2\Runtime\Http\ResponseHandler.cs:226
at Unity.Services.Lobbies.Apis.Lobby.LobbyApiClient.GetLobbyAsync (Unity.Services.Lobbies.Lobby.GetLobbyRequest request, Unity.Services.Lobbies.Configuration operationConfiguration) [0x001b2] in .\Library\PackageCache\com.unity.services.lobby@1.1.2\Runtime\Apis\LobbyApi.cs:423
at Unity.Services.Lobbies.Internal.WrappedLobbyService.TryCatchRequest[TRequest,TReturn] (System.String api, System.Func`3[T1,T2,TResult] func, TRequest request) [0x0006b] in .\Library\PackageCache\com.unity.services.lobby@1.1.2\Runtime\SDK\WrappedLobbyService.cs:397
--- End of inner exception stack trace ---
at Unity.Services.Lobbies.Internal.WrappedLobbyService.ResolveErrorWrapping (Unity.Services.Lobbies.LobbyExceptionReason reason, System.Exception exception) [0x000bf] in .\Library\PackageCache\com.unity.services.lobby@1.1.2\Runtime\SDK\WrappedLobbyService.cs:459
at Unity.Services.Lobbies.Internal.WrappedLobbyService.TryCatchRequest[TRequest,TReturn] (System.String api, System.Func`3[T1,T2,TResult] func, TRequest request) [0x0010b] in .\Library\PackageCache\com.unity.services.lobby@1.1.2\Runtime\SDK\WrappedLobbyService.cs:402
at Unity.Services.Lobbies.Internal.WrappedLobbyService.GetLobbyAsync (System.String lobbyId) [0x00072] in .\Library\PackageCache\com.unity.services.lobby@1.1.2\Runtime\SDK\WrappedLobbyService.cs:134
at Unity.Services.Lobbies.Internal.LobbyChannel.ProcessEvent (Unity.Services.Lobbies.ILobbyChanges nextToProcess, LobbyEventCallbacks callbacks) [0x000cf] in .\Library\PackageCache\com.unity.services.lobby@1.1.2\Runtime\SDK\LobbyUpdates\Internal\LobbyChannel.cs:188
at Unity.Services.Lobbies.Internal.LobbyChannel.HandleLobbyChanges (Unity.Services.Lobbies.ILobbyChanges changes, LobbyEventCallbacks callbacks) [0x001a8] in .\Library\PackageCache\com.unity.services.lobby@1.1.2\Runtime\SDK\LobbyUpdates\Internal\LobbyChannel.cs:155
UnityEngine.Logger:Log (UnityEngine.LogType,string,object)
Unity.Services.Lobbies.Logger:LogException (System.Exception) (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/Utils/Logger.cs:18)
Unity.Services.Lobbies.Internal.LobbyChannel/<HandleLobbyChanges>d__16:MoveNext () (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/SDK/LobbyUpdates/Internal/LobbyChannel.cs:159)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetException (System.Exception)
Unity.Services.Lobbies.Internal.LobbyChannel/<ProcessEvent>d__17:MoveNext () (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/SDK/LobbyUpdates/Internal/LobbyChannel.cs:200)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Models.Lobby>:SetException (System.Exception)
Unity.Services.Lobbies.Internal.WrappedLobbyService/<GetLobbyAsync>d__13:MoveNext () (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/SDK/WrappedLobbyService.cs:136)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Response`1<Unity.Services.Lobbies.Models.Lobby>>:SetException (System.Exception)
Unity.Services.Lobbies.Internal.WrappedLobbyService/<TryCatchRequest>d__26`2<Unity.Services.Lobbies.Lobby.GetLobbyRequest, Unity.Services.Lobbies.Models.Lobby>:MoveNext () (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/SDK/WrappedLobbyService.cs:433)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Response`1<Unity.Services.Lobbies.Models.Lobby>>:SetException (System.Exception)
Unity.Services.Lobbies.Apis.Lobby.LobbyApiClient/<GetLobbyAsync>d__13:MoveNext () (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/Apis/LobbyApi.cs:424)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Http.HttpClientResponse>:SetResult (Unity.Services.Lobbies.Http.HttpClientResponse)
Unity.Services.Lobbies.Http.HttpClient/<MakeRequestAsync>d__1:MoveNext () (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/Http/HttpClient.cs:41)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Http.HttpClientResponse>:SetResult (Unity.Services.Lobbies.Http.HttpClientResponse)
Unity.Services.Lobbies.Http.HttpClient/<CreateWebRequestAsync>d__3:MoveNext () (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/Http/HttpClient.cs:56)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Http.HttpClientResponse>:SetResult (Unity.Services.Lobbies.Http.HttpClientResponse)
Unity.Services.Lobbies.Http.HttpClient/<CreateHttpClientResponse>d__4:MoveNext () (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/Http/HttpClient.cs:84)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Http.HttpClientResponse>:SetResult (Unity.Services.Lobbies.Http.HttpClientResponse)
Unity.Services.Lobbies.Http.HttpClient/<>c__DisplayClass4_0/<<CreateHttpClientResponse>b__0>d:MoveNext () (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/Http/HttpClient.cs:81)
System.Threading.Tasks.TaskCompletionSource`1<Unity.Services.Lobbies.Http.HttpClientResponse>:SetResult (Unity.Services.Lobbies.Http.HttpClientResponse)
Unity.Services.Lobbies.Http.UnityWebRequestHelpers/<>c__DisplayClass0_0:<GetAwaiter>b__0 (UnityEngine.AsyncOperation) (at ./Library/PackageCache/com.unity.services.lobby@1.1.2/Runtime/Http/UnityWebRequestHelpers.cs:34)
UnityEngine.AsyncOperation:InvokeCompletionEvent ()