Search Unity

Question [Matchmaker] BadRequest (21400)

Discussion in 'Matchmaker' started by DeathPro, Feb 24, 2023.

  1. DeathPro

    DeathPro

    Joined:
    Jul 28, 2018
    Posts:
    91
    When I try to call the "CreateTicketAsync" callback like in this example, I initialize the Unity Services and authenticate myself previously and Multiplay set up. What things I could miss? I set up the matchmaker in the Unity Dashboard. Do I have to do something else before calling "CreateTicketAsync"?

    Unity: 2021.3.14f1
    Multiplay: 1.0.0-pre.7
    Matchmaker: 1.0.0-pre.14

    Example Code:
    Code (CSharp):
    1. private async Task CreateTicket()
    2.         {
    3.             var attributes = new Dictionary<string, object>();
    4.             var players = new List<Player>
    5.             {
    6.                 new(AuthenticationService.Instance.PlayerId)
    7.             };
    8.            
    9.             // Set options for matchmaking
    10.             var options = new CreateTicketOptions("MainWorld", attributes);
    11.            
    12.             // Create ticket
    13.             var ticketResponse = await MatchmakerService.Instance.CreateTicketAsync(players, options);
    14.  
    15.             // Print the created ticket id
    16.             Debug.LogFormat($"Created ticket with id: {ticketResponse.Id}");
    17.         }
    Errors:


    Code (CSharp):
    1. [Matchmaker]: BadRequest (21400)
    2. Title: Bad Request
    3. Errors:
    4. {"error":["No config found for upid 758efb56-0ce6-46cf-a4ff-ac1eff77c195 and env 4adef20a-8ca3-4acf-b7fc-43a2e817ac82"]}
    5.  
    6. UnityEngine.Logger:LogError (string,object)
    7. Unity.Services.Matchmaker.Logger:LogError (object) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/Utils/Logger.cs:17)
    8. Unity.Services.Matchmaker.WrappedMatchmakerService:ResolveErrorWrapping (Unity.Services.Matchmaker.MatchmakerExceptionReason,System.Exception) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:322)
    9. Unity.Services.Matchmaker.WrappedMatchmakerService/<TryCatchRequest>d__14`2<Unity.Services.Matchmaker.Tickets.CreateTicketRequest, Unity.Services.Matchmaker.Models.CreateTicketResponse>:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:251)
    10. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Response`1<Unity.Services.Matchmaker.Models.CreateTicketResponse>>:SetException (System.Exception)
    11. Unity.Services.Matchmaker.Apis.Tickets.TicketsApiClient/<CreateTicketAsync>d__7:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Apis/TicketsApi.cs:122)
    12. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
    13. Unity.Services.Matchmaker.Http.HttpClient/<MakeRequestAsync>d__1:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/HttpClient.cs:41)
    14. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
    15. Unity.Services.Matchmaker.Http.HttpClient/<CreateWebRequestAsync>d__3:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/HttpClient.cs:56)
    16. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
    17. Unity.Services.Matchmaker.Http.HttpClient/<CreateHttpClientResponse>d__4:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/HttpClient.cs:84)
    18. System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
    19. Unity.Services.Matchmaker.Http.HttpClient/<>c__DisplayClass4_0/<<CreateHttpClientResponse>b__0>d:MoveNext () (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/HttpClient.cs:81)
    20. System.Threading.Tasks.TaskCompletionSource`1<Unity.Services.Matchmaker.Http.HttpClientResponse>:SetResult (Unity.Services.Matchmaker.Http.HttpClientResponse)
    21. Unity.Services.Matchmaker.Http.UnityWebRequestHelpers/<>c__DisplayClass0_0:<GetAwaiter>b__0 (UnityEngine.AsyncOperation) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/UnityWebRequestHelpers.cs:34)
    22. UnityEngine.AsyncOperation:InvokeCompletionEvent ()
    23.  

    Code (CSharp):
    1. HttpException`1: (400) HTTP/1.1 400 Bad Request
    2. Unity.Services.Matchmaker.Http.ResponseHandler.HandleAsyncResponse (Unity.Services.Matchmaker.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/ResponseHandler.cs:122)
    3. Unity.Services.Matchmaker.Http.ResponseHandler.HandleAsyncResponse[T] (Unity.Services.Matchmaker.Http.HttpClientResponse response, System.Collections.Generic.Dictionary`2[TKey,TValue] statusCodeToTypeMap) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Http/ResponseHandler.cs:226)
    4. Unity.Services.Matchmaker.Apis.Tickets.TicketsApiClient.CreateTicketAsync (Unity.Services.Matchmaker.Tickets.CreateTicketRequest request, Unity.Services.Matchmaker.Configuration operationConfiguration) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/Apis/TicketsApi.cs:121)
    5. Unity.Services.Matchmaker.WrappedMatchmakerService.TryCatchRequest[TRequest,TReturn] (System.Func`3[T1,T2,TResult] func, TRequest request) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:228)
    6. Rethrow as MatchmakerServiceException: HTTP/1.1 400 Bad Request
    7. Unity.Services.Matchmaker.WrappedMatchmakerService.ResolveErrorWrapping (Unity.Services.Matchmaker.MatchmakerExceptionReason reason, System.Exception exception) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:328)
    8. Unity.Services.Matchmaker.WrappedMatchmakerService.TryCatchRequest[TRequest,TReturn] (System.Func`3[T1,T2,TResult] func, TRequest request) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:251)
    9. Unity.Services.Matchmaker.WrappedMatchmakerService.CreateTicketAsync (System.Collections.Generic.List`1[T] players, Unity.Services.Matchmaker.CreateTicketOptions options) (at Library/PackageCache/com.unity.services.matchmaker@1.0.0-pre.14/Runtime/SDK/WrappedMatchmakerService.cs:55)
    10. Asteroids_Host_Simple.Other.ApplicationController.CreateTicket () (at Assets/Asteroids-Host-Simple/Other/ApplicationController.cs:95)
    11. Asteroids_Host_Simple.Other.ApplicationController.LaunchInMode (System.Boolean isServer, System.String profileName) (at Assets/Asteroids-Host-Simple/Other/ApplicationController.cs:76)
    12. Asteroids_Host_Simple.Other.ApplicationController.Start () (at Assets/Asteroids-Host-Simple/Other/ApplicationController.cs:34)
    13. System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) (at <d6232873609549b8a045fa15811a5bd3>:0)
    14. UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <bae255e3e08e46f7bc2fbd23dde96338>:0)
    15. UnityEngine.UnitySynchronizationContext.Exec () (at <bae255e3e08e46f7bc2fbd23dde96338>:0)
    16. UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at <bae255e3e08e46f7bc2fbd23dde96338>:0)
     
  2. lucy-unity

    lucy-unity

    Unity Technologies

    Joined:
    Apr 7, 2021
    Posts:
    18
    Hi, thanks for your question. Are you still experiencing this issue? I can see in the last 24 hours that a couple of tickets were successfully created for your project and a Multiplay allocation was requested.

    The steps you took sound right. The error would suggest that the matchmaker is unable to find the config that you set up through UDash. Is it possible that the matchmaker was set up for a different environment than the one you were trying to hit with this request?
     
    DeathPro likes this.
  3. DeathPro

    DeathPro

    Joined:
    Jul 28, 2018
    Posts:
    91
    Thank you for your response.

    Yes, luckily I solved the issue. There was 2 different environment one for Production and one for Development. When I looked at the URL while at Multiplayer Dashboard, I realised there were IDs that match this error. Then I deleted Development Environment so there is only one Environment left. And then it worked :)

    But I suggest that this error could be more human-friendly. Maybe the error can indicate explicitly that the problem is actually about a different environment setup
     
  4. airburst_studios

    airburst_studios

    Joined:
    Jan 7, 2023
    Posts:
    37
    Well that's not a proper solution. How can one change the environment the ticket is being created towards? I also have two environments where development is the only one properly setup. How can I tell MatchmakerService to create a ticket in that environment to avoid the error?
     
    andreyshade likes this.
  5. airburst_studios

    airburst_studios

    Joined:
    Jan 7, 2023
    Posts:
    37
    @DeathPro


    Code (CSharp):
    1. var options = new InitializationOptions();
    2. options.SetEnvironmentName("dev");
    3.  
    4. await UnityServices.InitializeAsync(options);
    This will help defining an environment beforehand. That's what it fixed for me proplery
     
    shinichikudo997 and DeathPro like this.
  6. guillaumedUnity

    guillaumedUnity

    Unity Technologies

    Joined:
    Apr 1, 2021
    Posts:
    36
    Yes, this will force the Player Auth SDK to fetch a token for the dev environment. By defaut the environment is set to Production