Search Unity

Question 403 Forbidden (used to work before with same code)

Discussion in 'Lobby' started by aazzolini, Nov 10, 2021.

  1. aazzolini

    aazzolini

    Joined:
    Sep 7, 2019
    Posts:
    8
    Hi , I have been using lobby for the last weeks and it had been working fine. Today I started getting consistent 403 Forbidden when creating the lobby. (Creating the relay still works). Also I checked that I still have the "Lobby On" toggle enabled on the dashboard.

    Is there any change in permissions required to create a Lobby?


    The code goes like this:

    (Creating the Relay succeeds).

    Code (CSharp):
    1.  
    2.  
    3.     public struct RelayServerData
    4.     {
    5.         public string joinCode;
    6.         public string ipv4Address;
    7.         public ushort port;
    8.         public byte[] allocationIdBytes;
    9.         public byte[] keyBytes;
    10.         public byte[] connectionDataBytes;
    11.         public byte[] hostConnectionDataBytes;
    12.         public bool isHost;
    13.     }
    14.  
    15.     public async Task<RelayServerData> CreateRelay()
    16.     {
    17.         Allocation allocation;
    18.         allocation = await Relay.Instance.CreateAllocationAsync(4);
    19.         Debug.Log($"Host ConnectionData: {ByteArrayToString(allocation.ConnectionData)}");
    20.         Debug.Log($"Host AllocationId: {allocation.AllocationId}");
    21.         string createdJoinCode = await Relay.Instance.GetJoinCodeAsync(allocation.AllocationId);
    22.         Debug.Log("Relay Join code: " + createdJoinCode);
    23.         return new RelayServerData
    24.         {
    25.             joinCode = createdJoinCode,
    26.             ipv4Address = allocation.RelayServer.IpV4,
    27.             port = (ushort)allocation.RelayServer.Port,
    28.             allocationIdBytes = allocation.AllocationIdBytes,
    29.             keyBytes = allocation.Key,
    30.             connectionDataBytes = allocation.ConnectionData,
    31.             hostConnectionDataBytes = allocation.ConnectionData,
    32.             isHost = true,
    33.         };
    34.     }
    35.  
    36.     public async void CreateLobby()
    37.     {
    38.         // these work
    39.         await UnityServices.InitializeAsync();
    40.         await AuthenticationService.Instance.SignInAnonymouslyAsync();
    41.         var relayData = await CreateRelay();
    42.  
    43.         // this fails with 403
    44.         lobby = await Lobbies.Instance.CreateLobbyAsync("mylobby", 4, new CreateLobbyOptions
    45.         {
    46.             Player = new Unity.Services.Lobbies.Models.Player(
    47.                 id: AuthenticationService.Instance.PlayerId,
    48.                 connectionInfo: relayData.joinCode,
    49.                 allocationId: relayData.allocationIdBytes.ToString()
    50.             ),
    51.         });
    52.  
     
  2. aazzolini

    aazzolini

    Joined:
    Sep 7, 2019
    Posts:
    8
    Oh, worked now. Maybe some intermittent issue? Weird that it shows as Forbidden as opposed to e.g. connection error or other.
     
  3. Unity_3D_Alex

    Unity_3D_Alex

    Unity Technologies

    Joined:
    Nov 11, 2020
    Posts:
    10
    Hi there,

    I believe there was an intermittent issue earlier today where authenticated calls to the Lobby service were occasionally returning 403 Forbidden, which looks to be resolved. As of right now, I'm testing your code and am able to create lobbies without any errors.

    If this pops up again, please also feel free to submit a ticket.

    Cheers :)