Search Unity

Question Testing Lobby & Relay with multiple instances on single device.

Discussion in 'Authentication' started by Nevey, Nov 25, 2021.

  1. Nevey

    Nevey

    Joined:
    Nov 23, 2012
    Posts:
    6
    Hi!

    I'm working with Lobby and Relay, and I'm at the point where I'd like to test my game with 2 players. However, playing the game on the same machine won't work when logging in anonymously via the required authentication service as it's using the device token as identifier, causing the Lobby to think the same user is trying to connect for a second time. Which is in fact correct.

    So when running two instances of the game next to each other, the second instance won't be able to connect to the lobby after the first instance has already done so. I can't find a way on either the forums or in the documentation to create my own token to get around this, albeit just for development purposes so I don't require multiple devices.

    Any suggestions?

    Cheers!
     
    Nerkosis and Leos924 like this.
  2. mahdik_unity

    mahdik_unity

    Unity Technologies

    Joined:
    Sep 16, 2021
    Posts:
    15
    Hi Nevey

    This is a feature that will be added in our next release. The team is currently working on it and soon it will be possible to support multiple sessions on a single device.

    Cheers
     
    Leos924 likes this.
  3. Leos924

    Leos924

    Joined:
    Feb 14, 2015
    Posts:
    11
    I was just about to post the same inquiry and saw this post.
    Hopefully this can be released soon, it's a little difficult to do integration testing having to build, publish to steam and create a session with a tester :D
     
  4. Nevey

    Nevey

    Joined:
    Nov 23, 2012
    Posts:
    6
    A solution to get this working on one machine is to rename the product name of the other unity project, then it will just work
     
  5. mahdik_unity

    mahdik_unity

    Unity Technologies

    Joined:
    Sep 16, 2021
    Posts:
    15
    We are currently working on adding the ability to have multiple profiles as well. More details are coming no later than January.

    Our team also created a beta survey for our Authentication product (to understand what's working well, what's missing, etc). If you have a moment, we would love to get your feedback. We're using feedback/questions like yours to help prioritize and guide our 2022 plans. Let us know if there are other sign-in providers that you would find useful in your projects.
     
  6. Nevey

    Nevey

    Joined:
    Nov 23, 2012
    Posts:
    6
    Thanks for the update. I've followed the survey. Hope it helps.

    Cheers!
     
  7. erickb_unity

    erickb_unity

    Unity Technologies

    Joined:
    Sep 1, 2021
    Posts:
    92
    Hello Nevey,

    Just an update to say we have released 1.0.0-pre.37 which has support for multiple profiles.

    You can find documentation on the new feature here: https://docs.unity.com/authentication/ProfileManagement.htm

    You'll need to set unique profiles on each instance running in order to get different players for your test scenario.

    Let us know if you have any other questions.
     
    Nevey and SebT_Unity like this.
  8. RR7

    RR7

    Joined:
    Jan 9, 2017
    Posts:
    254
    if i want to log two local players into a lobby. into the same game. a 2 player game in one instance, not two single player games in separate instances, am I right in assuming here that his is not possible on UGS as the authentication does not support it, and therefore the lobby cannot support it?

    thus furthermore the whole new UGS system is a no-no for any game using 2 local players connecting online?
     
  9. rahadinabak

    rahadinabak

    Joined:
    Nov 12, 2020
    Posts:
    3
    Hello,
    I fixed that issue creating a new anonymous account below, worked with ParrelSync well.

    Code (CSharp):
    1. #if UNITY_EDITOR
    2.             AuthenticationService.Instance.ClearSessionToken();
    3.             #endif
    4.  
    5.             await AuthenticationService.Instance.SignInAnonymouslyAsync();
     
  10. neviovalsa

    neviovalsa

    Joined:
    Jun 24, 2019
    Posts:
    52
    Support for multiple profiles is implemented but might be not working as expected.

    I get a problem where I'm able to login with a Profile (which creates a PlayerId) and create a Lobby.

    Playing again I create a new Profile (and new PlayerId), and when creating a new lobby, it creates it with the HostId created in the previous Play session.

    If attempting to create the lobby specifying the new player Id in CreateLobbyOptions with

    Code (CSharp):
    1. return new Player(
    2.             id: AuthenticationService.Instance.PlayerId,
    3.             data: new Dictionary<string, PlayerDataObject>()
    4.             {
    5.                 { "PlayerName", new PlayerDataObject(PlayerDataObject.VisibilityOptions.Member, _playerName) }
    6.             });
    I get the following error.

    Lobby]: ValidationError, (16000). Message: request failed validation
    UnityEngine.Logger:LogError (string,object)
    Unity.Services.Lobbies.Logger:LogError (object) (at Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Utils/Logger.cs:17)
    Unity.Services.Lobbies.Internal.WrappedLobbyService:ResolveErrorWrapping (Unity.Services.Lobbies.LobbyExceptionReason,System.Exception) (at Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/SDK/WrappedLobbyService.cs:417)
    Unity.Services.Lobbies.Internal.WrappedLobbyService/<TryCatchRequest>d__20`2<Unity.Services.Lobbies.Lobby.CreateLobbyRequest, Unity.Services.Lobbies.Models.Lobby>:MoveNext () (at Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/SDK/WrappedLobbyService.cs:359)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Response`1<Unity.Services.Lobbies.Models.Lobby>>:SetException (System.Exception)
    Unity.Services.Lobbies.Apis.Lobby.LobbyApiClient/<CreateLobbyAsync>d__6:MoveNext () (at Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Apis/LobbyApi.cs:235)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Http.HttpClientResponse>:SetResult (Unity.Services.Lobbies.Http.HttpClientResponse)
    Unity.Services.Lobbies.Http.HttpClient/<MakeRequestAsync>d__3:MoveNext () (at Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:47)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Http.HttpClientResponse>:SetResult (Unity.Services.Lobbies.Http.HttpClientResponse)
    Unity.Services.Lobbies.Http.HttpClient/<CreateWebRequestAsync>d__7:MoveNext () (at Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:138)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Lobbies.Http.HttpClientResponse>:SetResult (Unity.Services.Lobbies.Http.HttpClientResponse)
    Unity.Services.Lobbies.Http.HttpClient/<>c__DisplayClass7_0/<<CreateWebRequestAsync>b__0>d:MoveNext () (at Library/PackageCache/com.unity.services.lobby@1.0.3/Runtime/Http/HttpClient.cs:135)
    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.0.3/Runtime/Http/UnityWebRequestHelpers.cs:34)
    UnityEngine.AsyncOperation:InvokeCompletionEvent ()


    Note: when script is recompiled for any reason, I'm able to repeat the process, where I get to create a lobby once.

    I'm currently trying to create a minimal repro, but maybe somebody could help already?
     
  11. unity_esIKA_rGB50dlg

    unity_esIKA_rGB50dlg

    Joined:
    Dec 31, 2021
    Posts:
    5
    Setting unique profiles didn't really solve my problem of having multiple builds on the same device trying to connect to a lobby. The problem for me was the PlayerId, so not sure what the profiles is for. Although, I fixed my problem by using the following code. Similar to rahads post.
    private async void Awake() {
    if (!AuthenticationService.Instance.IsSignedIn)
    {
    AuthenticationService.Instance.ClearSessionToken(); // DELETE WHEN I AM DONE, THIS IS IMPORTANT. THIS IS PRETTY MUCH MAKING IT SO WE CREATE A NEW AUTHENTIFICATION FOR THE PLAYER EACH BUILD
    await AuthenticationService.Instance.SignInAnonymouslyAsync();
    playerId = AuthenticationService.Instance.PlayerId;
    Debug.Log(playerId);
    }
    }