I can't figure out how to make Unity Relay work on WebGL

So I’ve been working on a multiplayer game and I wanted to publish it to itch.io for people with Chromebooks to play as well (And any other systems) so I did some research and found out that you need to set the encryption type or connection type to “wss” but I am not using that version of the packages. I have:

  • Unity Transport 2.6.0
  • Netcode for GameObjects 2.7.0
  • Unity Editor 6.2

I was using this initially to get clients and hosts connected:

// Host:
Allocation allocation = await RelayService.Instance.CreateAllocationAsync(3);
string joinCode = await RelayService.Instance.GetJoinCodeAsync(allocation.AllocationId);

NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(
    allocation.RelayServer.IpV4, 
    (ushort)allocation.RelayServer.Port, 
    allocation.AllocationIdBytes, 
    allocation.Key, 
    allocation.ConnectionData, 
    allocation.ConnectionData, 
    true
);
joinCodeText.text = "Start " + joinCode;

NetworkManager.Singleton.StartHost();

// Client:
JoinAllocation joinAllocation = await RelayService.Instance.JoinAllocationAsync(joinCode);

NetworkManager.Singleton.GetComponent<UnityTransport>().SetRelayServerData(
    joinAllocation.RelayServer.IpV4, 
    (ushort)joinAllocation.RelayServer.Port, 
    joinAllocation.AllocationIdBytes, 
    joinAllocation.Key, 
    joinAllocation.ConnectionData,
    joinAllocation.HostConnectionData, 
    true
);

NetworkManager.Singleton.StartClient();

And I’ve seen many places telling me to use something like SetRelayServerData(Allocation, connectionType) but when I try to do so, I get an error that “No overload method takes those arguments”

I’ve also tried to downgrade Unity Trasnsport to a version that uses that method but I couldn’t find a way to do so? I also DID set Use Web Sockets and Use Encryption to True (Checked) in the Inspector.

If anyone can help me with this, I’d greatly appreciate it! Thanks in advance.

You can find an example of how to obtain the Relay server data from an allocation here. For the SetRelayServerData call it basically boils down to this:

transport.SetRelayServerData(AllocationUtils.ToRelayServerData(allocation, "wss"));

Also make sure you are using the combined Multiplayer Services package (com.unity.services.multiplayer) and not the standalone Relay package (com.unity.services.relay) which is not supported anymore in Unity 6. With the combined services package it’s also now possible to use the sessions API to start multiplayer sessions with Relay. This API simplifies things quite a bit, although if you wish you can still configure Relay manually.

This worked! Thank you so much!