If I joined a lobby and leave that lobby, then I log out of my player’s account and onto another one, lobby events stops working. When I log back into the first account, lobby events starts functioning again.
There appears to be a bug with switching player accounts. The lobby does not properly clean up after disconnecting. The first player account that connects to the service will be the only account that works.
I think this is a bug with Lobby service. Has anyone else had this issue? Is there a method I need to call to clean up the Lobby service properly?
I’m using the latest version of Lobby (1.1.0-pre.5).
Here is the stack trace:
RequestFailedException: unauthorized
Unity.Services.Wire.Internal.CommandManager.WaitForCommandAsync (System.UInt32 id) (at ./Library/PackageCache/com.unity.services.wire@1.1.8/Runtime/Centrifuge/CommandManager.cs:55)
Unity.Services.Wire.Internal.Client.SendCommandAsync (System.UInt32 id, Unity.Services.Wire.Protocol.Internal.Command command) (at ./Library/PackageCache/com.unity.services.wire@1.1.8/Runtime/Centrifuge/Client.cs:114)
Unity.Services.Wire.Internal.Client.SubscribeAsync (Unity.Services.Wire.Internal.Subscription subscription) (at ./Library/PackageCache/com.unity.services.wire@1.1.8/Runtime/Centrifuge/Client.cs:581)
Unity.Services.Wire.Internal.Client+<>c__DisplayClass40_0.b__1 (System.Threading.Tasks.TaskCompletionSource`1[TResult] completionSource) (at ./Library/PackageCache/com.unity.services.wire@1.1.8/Runtime/Centrifuge/Client.cs:612)
Unity.Services.Lobbies.Internal.LobbyChannel.SubscribeAsync () (at ./Library/PackageCache/com.unity.services.lobby@1.1.0-pre.5/Runtime/SDK/LobbyUpdates/Internal/LobbyChannel.cs:50)
Rethrow as LobbyServiceException: There was an error when trying to connect to the lobby service for events. Ensure a valid Lobby ID was sent. Error Code[23007].
Unity.Services.Lobbies.Internal.LobbyChannel.SubscribeAsync () (at ./Library/PackageCache/com.unity.services.lobby@1.1.0-pre.5/Runtime/SDK/LobbyUpdates/Internal/LobbyChannel.cs:59)
Unity.Services.Lobbies.Internal.WrappedLobbyService.SubscribeToLobbyEventsAsync (System.String lobbyId, LobbyEventCallbacks lobbyEventCallbacks) (at ./Library/PackageCache/com.unity.services.lobby@1.1.0-pre.5/Runtime/SDK/WrappedLobbyService.cs:98)
I’m not sure you’re understanding the problem I’m describing. The issue is not with lobbies themselves, but with the new Lobby Events features connected via Wire. Switching lobbies work fine. The issue is with logging out of Player Accounts and logging into a different account. The real-time Lobby Events no longer functions because it thinks I’m a different Player Account and fails to authenticate.
Hey lsaeteurn,
I’m working on the Wire package, thanks for reaching out!
I will need more data to understand what is going on, but indeed, changing identity mid game wasn’t a use case for us until recently.
Can you please setup a define to activate Wire extended logging?
You just have to go to your Player Settings, and add ENABLE_UNITY_WIRE_VERBOSE_LOGGING to the scripting define symbols.
Then show us the logs please 
Okay, here is the log. If you need more detail, let me know.
1st Subscribe command:
[Wire]: sending SUBSCRIBE command: {“id”:3,“subscribe”:{“channel”:“$lobby!!!YNNBvPeMf69Xq9okv3QJ8S!!!7c4cd2f0-dff8-413c-99be-0b65811f0679!!!4ed646cd-a399-4f1b-9b14-865b8d78ac8a”,“token”:“eyJhbGciOiJSUzI1NiIsImtpZCI6IkxvYmJ5OmQ4MGM1ZjU0LWM0NjAtNDQ5Zi04ZjlmLTk1MjRhNzIzYTdkYSIsInR5cCI6IkpXVCJ9.eyJlbnZpcm9ubWVudElkIjoiNGVkNjQ2Y2QtYTM5OS00ZjFiLTliMTQtODY1YjhkNzhhYzhhIiwiZXhwIjoxNjg5NjIxMTY5LCJpYXQiOjE2ODk2MTc1NjksImlzcyI6ImxvYmJ5IiwibmJmIjoxNjg5NjE3NTY5LCJwcm9qZWN0SWQiOiI3YzRjZDJmMC1kZmY4LTQxM2MtOTliZS0wYjY1ODExZjA2NzkiLCJyZXNvdXJjZSI6IllOTkJ2UGVNZjY5WHE5b2t2M1FKOFMiLCJzZXJ2aWNlSWQiOiJsb2JieSIsInN1YiI6IjRKSHYyaGNCZFpMTVBqRnNwaHFzaGpsM0hEbHkifQ.erHCUhEeBDl49tgCHvB0e6y4hZ9a5JNTJ3wLCqevwxlbrGePw4CeqjYyMurv6qGviwm6R26o41qdtOmCrjRXaAcIgC6ycxFNDk_i9AWa0Ad0TYwNO_xFFSXikhrBbdJP5yaNAEczoSLGXXV9gFBSlYl4B1Kw2JHnlX6d-blO8GTtBfhl5v9hTyZSIkaGvRgKMzl_8dJvDOuykut1hPTsissVo3CK65-nUWDLvg-24vxixVDB7o1pZxGd5G59a0LWfCNLFVTep_IF59GoSLhCqa2t4Rh6R24nak4lqR4y4a_a0-lxnEXZGhkM0R7oRFRFyMQLeXzo7bLDSJgUdsvy1Q”,“recover”:false,“offset”:0}}
2nd Subscribe command:
[Wire]: sending SUBSCRIBE command: {“id”:10,“subscribe”:{“channel”:“$lobby!!!23U3tQdXMnbmydpZZHYknb!!!7c4cd2f0-dff8-413c-99be-0b65811f0679!!!4ed646cd-a399-4f1b-9b14-865b8d78ac8a”,“token”:“eyJhbGciOiJSUzI1NiIsImtpZCI6IkxvYmJ5OmQ4MGM1ZjU0LWM0NjAtNDQ5Zi04ZjlmLTk1MjRhNzIzYTdkYSIsInR5cCI6IkpXVCJ9.eyJlbnZpcm9ubWVudElkIjoiNGVkNjQ2Y2QtYTM5OS00ZjFiLTliMTQtODY1YjhkNzhhYzhhIiwiZXhwIjoxNjg5NjIxMzExLCJpYXQiOjE2ODk2MTc3MTEsImlzcyI6ImxvYmJ5IiwibmJmIjoxNjg5NjE3NzExLCJwcm9qZWN0SWQiOiI3YzRjZDJmMC1kZmY4LTQxM2MtOTliZS0wYjY1ODExZjA2NzkiLCJyZXNvdXJjZSI6IjIzVTN0UWRYTW5ibXlkcFpaSFlrbmIiLCJzZXJ2aWNlSWQiOiJsb2JieSIsInN1YiI6InJmb1pwMDNSek9SMTJxV2FoR2Mwc0dHUHpNRDMifQ.wwMsKpDV99kor_gEStZcSxH0atzQnzd13dZeo8maUkmr2rRWIAIQGlMPfA2-UAntQ6-P8hgcfnYed5b3TG6pa4ErYUMEttGdJS5ggWhSzRxoZwujKnn6I_E6tCEd6JbfcJndajABVbXw48MwrKq4S1DEc3tK3C-zZDx8OJ17YEv0mkG0GMJk0PN6QStzf3S7VMQtSfckefo_7bes7xMOjzpOFlIlNU2PhnNOmTbwvPKnkS_JTbYNK4fR5cwga6zTV_MN-kbnj3k0G5Q5L68SXkaJtdbeNxAyYhzVWnGbNuQhHxwSpaXba0TdaUnR_rO5LSs74T2EqIa9dPRgw_6zXw”,“recover”:false,“offset”:0}}
Looks like the same token is being used by both accounts. Since they are different identities, they should probably have different tokens.
That’s strange, you are using Wire 1.1.8, and at no moment you are seeing this log?
PlayerID changed to [{ playerId }], next action: { action }
And yes, if the player id changes, they should use a different token, will see on lobby sdk side and get back to you
Not seeing that. Is there a proper way to logout? I’m currently using Anonymous login and just switching profiles. Maybe this only works with the new Unity username/password Login which I haven’t got around to implementing yet.
how do you switch profile?
I call this to logout:
AuthenticationService.Instance.SignOut();
Then I call this to switch profiles and then login:
var authentication = AuthenticationService.Instance;
authentication.SwitchProfile(profileId);
authentication.SignInAnonymouslyAsync();
mhhh, that way of switching is correct should indeed trigger that log on Wire 1.1.8.
Will look into that, but this does not explain why the tokens are identical.
One last thing, in your snippet I don’t see you awaiting the SignInAnonymously() function, so if it throws you might not see it!
Possibly it could trigger a race condition if you are not awaiting before sending the second subscribe command.
Basically, Wire is listening to the player id change event from the auth package to reinitialize the connection.
That was just a copy/paste example. I am definitely awaiting it. The subscription happens at a completely different time when I actually try to join or create a lobby.
1 Like
OK, just checked the tokens in jwt.io, they are actually different, with a different playerId, so that’s not the problem, it’s likely to be in Wire.
Out of curiosity, could you try the SignOut but with clearCredentials = true?
Okay, just tried it and same error. Nothing changed.
thanks, I will work on a repro on my side
1 Like
OK managed to have a repro with clearCredentials = false, but not with clearCredentials = true.
Can you please double check that the clearCredentials can’t work as a short term work around?
Here is the code I used to changed identity:
public async void ChangeIdentity()
{
try
{
AuthenticationService.Instance.SignOut(false);
AuthenticationService.Instance.SwitchProfile("default" + currentProfileId % profileIdCount);
await AuthenticationService.Instance.SignInAnonymouslyAsync();
Debug.Log("UAS ID: " + AuthenticationService.Instance.PlayerId);
currentProfileId++;
}
catch (Exception e)
{
Debug.LogException(e);
}
}
It seems to be working now by setting that to true. It failed the first time when I tried it and it also failed a couple more times in my tests.
So not 100% (probably 90%), but it’s good enough for now. Could be related to the fact that the Wire connection isn’t very stable (changes to Unsynced state randomly). I lose connection every 25-40 mins, but I can just simply reconnect when that happens.
Is passing TRUE the proper way to sign out?
Here’s the code I’m using:
Yeah, sounds right.
Right now calling authentication.SignOut(true) is a workaround for the current issue that’s a bit deeper in our systems. But it is as valid as calling it with false. It’s just telling Auth to not use the cached identity and renew it.
As for the random Wire disconnection, what’s expected is a disconnection every 60min, in any case, the Wire package is supposed to reconnect by itself and renew the subscriptions. You shouldn’t have to do a thing, so I’m not sure what you meant by “I can just simply reconnect when that happens”?