I am using the Lobby system and when a Client tries to join a lobby I get the following error:
HttpException`1: (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) [0x00000] in <00000000000000000000000000000000>:0
at Unity.Services.Lobbies.Http.ResponseHandler.HandleAsyncResponse[T] (Unity.Services.Lobbies.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) [0x00000] in <00000000000000000000000000000000>:0
at Unity.Services.Lobbies.Apis.Lobby.LobbyApiClient.JoinLobbyByIdAsync (Unity.Services.Lobbies.Lobby.JoinLobbyByIdRequest request, Unity.Services.Lobbies.Configuration operationConfiguration) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0
My Join Lobby code is as follows:
public async void JoinLobby(Lobby lobby) {
Player player = GetPlayer();
joinedLobby = await LobbyService.Instance.JoinLobbyByIdAsync(lobby.Id, new JoinLobbyByIdOptions {
Player = player
});
OnJoinedLobby?.Invoke(this, new LobbyEventArgs { lobby = lobby });
}
I dont have these errors on the host and the above error only fires when clients try and join the lobby. I am using Netcode for Gameobjects 2.1.1, Multiplayer Services 1.0.2.
This error is not happening in editor with multiplayer play mode, only when I run 2 Il2CPP Windows Builds.
So this error code is interesting, in a precise but albeit unpleasant sense, it is a microsoft error that is saying “No”, the HTTP request saying “Too many requests” is that it cannot handle all the data parcels being sent to and received from the server.
Not being the clients trying to join, it is hard to know their environment, google stated (Microsoft) it is a Windows 11 error. The fact it is ONLY firing when clients join, may well prove to be network issue rather than code. Are you able to replicate this issue in a test environment (Split your internet and or make virtual machines) ? It seems more server side than your code.
One question though you mention lobby = lobby in your code, if we assume your public async method which takes in lobby as a variable, where is the other lobby declared (Ill fabricate an example)
public void AddSomething(float thingtoAdd)
{
thingtoAdd = thingtoAdd;
//What is the original thing to add? where is it declared? why identical names?
}
}
In short, you declare a variable to be itself but if you take in that variable delcaring it to be itself wont work (unless it is prior declared)
int number;
void int AddNumber(int number){
number = 1;
number += number;
return number;
} //this returns 2 as number is declared as ONE in the method, then added to itself. Declare the number as 1 outside the method, then repeating this code gives you a sequence that is basically 1 + 1 = 2, 2+2 = 4 etc.
Hiya @ifehoward ,
Before considering this as a bug, let’s review a couple common cases.
That error is a standard rate limiting error code for services. Please review the rate limits for Unity Lobby here: Rate limits
Where is JoinLobby
getting called from? Ensure that the join isn’t happening in a loop (like Update) and getting called many times per second. Or if it is in such a loop you gate it with a conditional check of some sort.
Also, it sounds like you’re testing things locally with multiple clients? It’s possible the same user profile is being used on all those builds so join attempts in quick succession are likely to hit that rate limit. I’m assuming you’re using anonymous auth right now and not logging into specific users? So for clients you could generate a custom uuid and use that in the SwitchProfile
method. Something like this:
AuthenticationService.Instance.SwitchProfile(_profileName);
await AuthenticationService.Instance.SignInAnonymouslyAsync();
1 Like
Just encase anyone else has makes this mistake, I ended up resolving by implementing the following as suggested above:
AuthenticationService.Instance.SwitchProfile(playerName);
AuthenticationService.Instance.SignedIn += () =>
{
Debug.Log("Signed In " + AuthenticationService.Instance.PlayerId);
};
await AuthenticationService.Instance.SignInAnonymouslyAsync();
2 Likes