Hi,
I am using ngo, relay and lobby. I though we have to set player.allocationId so the ugs can make connection between the services. Here is what happens:
- If I set lobbyPlayer.allocationId to relayAllocation.id, client connection approvals are never true, whether I set it manually with the onConnectionApproval callback or leave it to networkmanager.
- If I remove only the code that sets lobbyPlayer.allocationId, relay connection works and clients are approved, either manually or by networkmanager automatically.
I am not reporting an issue or a bug, but I want to understand, why it behaves like that and what’s the use case for allocationId?
If it makes a difference, I do relayAllocation.allocationId.toString() while setting it since it’s type is not string but guid.
Edit:
It suddenly stopped working as before for 10 minutes and then started working again. No code changes. The system doesn’t seem reliable at all. Is there a way to pay for it and switch to a more reliable infrastructure?
Yes, you have to INSERT COIN before attempting to make a connection to make it reliable.
No, seriously, if something “online” doesn’t work perfectly every time you got to rule out first if the issue is on your side. There’s also the status page to check on any service issues.
From your description it sounds like you went all in - use Lobby, Relay, Networking and put it all together and nope, it doesn’t really work. You have to take baby steps to ensure that everything you do works perfectly fine. First, establish a local network connection. Then add Relay to the mix. Then setup a lobby without any connections. Then integrate the Lobby service with relay network connections.
Each step needs to be tested and verified as much as possible for every nook and cranny, like disconnecting, reconnecting, failures happening, and with network simulator testing unstable connections or manually pulling the plug to see what the timeout behaviour is like.
Pretty sure you made a doohickey somewhere so it would be best if you posted your code.
I agree with you, I think I improved my code and never seen any issue again. I’ll keep improving after having some proof of concept for myself that I understood netcode.
Do you know about the allocationId problem? That’s persistent, it doesn’t work with relay when I set lobbyplayer’s allocationId value, I wonder what is it for and is it okay to not use it while using relay.
Just bumping this for the multiplayer blitz event. About the lobby/relay allocation id part of the question.
Hi multiunitydev,
Thank you for the bump !
The Lobby Player AllocationId should indeed be set to the Relay Allocation Id for the integration between Lobby and Relay to be effective (and you are indeed right to use the toString
since the Player Allocation Id is a string
). Here is the documentation: Relay integration (unity.com)
This mechanism should not be impacting the onConnectionApproval
, we will have to look into it ! Which Unity version, SDK versions and Netcode for gameobjects versions are you using ?
If you are using Unity2022+, you might also consider using our new Multiplayer Services SDK (Here is the documentation: Multiplayer Services sessions for the Unity Engine). It bundles Lobby, Relay, Matchmaker and Game Server Hosting for easier use.
For example, as show in Create a session (unity.com), setting up as Session (which uses Lobby and Relay and starts Netcode for gameobjects under the hood) can be done this way
var options = new SessionOptions { MaxPlayers = 2 }.WithRelayNetwork();
var session = await MultiplayerService.Instance.CreateSessionAsync(options);
Debug.Log($"Session {session.Id} created! Join code: {session.Code}");
Please take into account that
- The Multiplayer Services SDK actually does bundle the standalone SDKs for Lobby, Relay, Matchmaker and Game Server Hosting. That is to say, the code you currently have should still be working when you replace Lobby and Relay SDKs by this one. You can then decide if you prefer to keep using Lobby and Relay (for more fine grain control) or switch to the Multiplayer Services SDK.
- The Multiplayer Services SDK is currently in preview (
1.0.0-pre.1
at the time of this reply). We are currently looking for feedback both on the SDK usage (how easy it is to use, if you find use cases not covered, …) and the documentation (how clear it is, how easy it is to get started, …).
- This SDK should not be impacting your usage of
onConnectionApproval
(once again, we will look into it).
Please keep the feedback coming !
UPDATE: Tried a repro after re-installing the services package but I don’t get any player exception anymore. So please ignore.
Since you mention that …
I made a build two days ago with the (most up to date) Services package, and upon running the Windows x64 dev build I received an exception right away without actually making use of the package. Can’t recall the exception but it was obviously coming from the mp services package. Thus I uninstalled the mp services package, made another build, exception was gone.
My build utilized NGO 2.0 and Relay, Dedicated Server packages.
Sorry, didn’t have time to make a testcase for this one but maybe that reminder is enough.
1 Like