LLAPI with WebGL AddWebsocketHost

Hi

Goal: Connect via LLAPI to server with WebGL
Problem: The following code works for standalone build and in editor. It also works for WebGL ONLY when run in the editor. This breaks when WebGL is built and run.

Unity Headless Linux Server code running in Editor

private void Start()
    {
        GlobalConfig config = new GlobalConfig();
        NetworkTransport.Init(config);

        //Host Topology
        ConnectionConfig cc = new ConnectionConfig();
        reliableChannel = cc.AddChannel(QosType.Reliable);
        unreliableChannel = cc.AddChannel(QosType.Unreliable);
        HostTopology topo = new HostTopology(cc, MAX_CONNECTIONS);

        //Adding hosts
        hostId = NetworkTransport.AddHost(topo, SERVER_PORT, null);
        webHostId = NetworkTransport.AddWebsocketHost(topo, SERVER_WEB_PORT, null);

        isStarted = true;

        Debug.Log("---Server Started---");

        game = new Game();
    }

Client Connection Code

    public void Connect()
    {
        GlobalConfig config = new GlobalConfig();
        NetworkTransport.Init(config);

        //Host Topology
        ConnectionConfig cc = new ConnectionConfig();
        reliableChannel = cc.AddChannel(QosType.Reliable);
        unreliableChannel = cc.AddChannel(QosType.Unreliable);
        HostTopology topo = new HostTopology(cc, MAX_CONNECTION);

#if UNITY_WEBGL
        hostId = NetworkTransport.AddWebsocketHost(topo, 0); //Breaks here in WebGL build
        connectionId = NetworkTransport.Connect(hostId, IP_ADDRESS, SERVER_WEB_PORT, 0, out error);
#else
        hostId = NetworkTransport.AddHost(topo, 0);
        connectionId = NetworkTransport.Connect(hostId, IP_ADDRESS, SERVER_PORT, 0, out error);
#endif

        connectionTime = Time.time;
        isConnected = true;
    }

Thank you

Having the same issue. I see so many ppl trying to get this going. All they really need to do is build in a native wss class and it will be peachy.
Some have said this works. Im trying it out now.

as far as I remember - remove

        hostId = NetworkTransport.AddWebsocketHost(topo, 0); //Breaks here in WebGL build
        connectionId = NetworkTransport.Connect(hostId, IP_ADDRESS, SERVER_WEB_PORT, 0, out error);

from client and remove all if else, then compile for web gl…
this call hostId = NetworkTransport.AddWebsocketHost(topo, 0); won’t be translated to js and will work on editor and standalone win/Mac/linux players…

other words; Client

public void Connect()
    {
        GlobalConfig config = new GlobalConfig();
        NetworkTransport.Init(config);
        //Host Topology
        ConnectionConfig cc = new ConnectionConfig();
        reliableChannel = cc.AddChannel(QosType.Reliable);
        unreliableChannel = cc.AddChannel(QosType.Unreliable);
        HostTopology topo = new HostTopology(cc, MAX_CONNECTION);
        hostId = NetworkTransport.AddHost(topo, 0);
        connectionId = NetworkTransport.Connect(hostId, IP_ADDRESS, SERVER_PORT, 0, out error);
        connectionTime = Time.time;
        isConnected = true;
    }