Hi i need help with unity webgl socket.ConnectAsync throwing error on webgl

Hi i need help with unity webgl socket.ConnectAsync throwing error on WebGL

WebSocket error: undefined

@manirana94 can you share the code you use to set up your socket in Unity WebGL builds?

For example did you follow the instructions and use code like:

#if UNITY_WEBGL && !UNITY_EDITOR
    ISocketAdapter adapter = new JsWebSocketAdapter();
#else
    ISocketAdapter adapter = new WebSocketAdapter();
#endif
var socket = Socket.From(client, adapter);

@novabyte Thank you for helping here is my code for socket connection.

 _client = new Client(scheme, host, port, serverKey, UnityWebRequestAdapter.Instance);
            _socket = _client.NewSocket();

            #if UNITY_WEBGL && !UNITY_EDITOR
            ISocketAdapter adapter = new JsWebSocketAdapter();
            #else
            ISocketAdapter adapter = new WebSocketAdapter();
            #endif
            _socket = Socket.From(_client, adapter);

            _socket.Closed += () => Debug.Log("Socket closed.");
            _socket.Connected += () => Debug.Log("Socket connected.");
            _socket.ReceivedError += e => Debug.Log("Socket error: " + e.Message);
            
            var udid = Guid.NewGuid().ToString();

            var sessionToken = NetworkUtils.GetAuthToken();
            if (string.IsNullOrEmpty(sessionToken) || (_session = Session.Restore(sessionToken)).IsExpired)
            {
                _session = await _client.AuthenticateDeviceAsync(udid);
                NetworkUtils.SaveDeviceID(udid);
                NetworkUtils.SaveAuthToken(_session.AuthToken);
            }
            await _socket.ConnectAsync(_session, true);

I got an error on _socket.ConnectAsync its return error WebSocket error: undefined on WebGL build