# Having problem with SocketException in WebGL build

**URL:** <https://forum.heroiclabs.com/t/having-problem-with-socketexception-in-webgl-build/4783>\
**Category:** Client Libraries\
**Tags:** sdk-unity\
**Created:** [December 22, 2023, 7:41am UTC](https://forum.heroiclabs.com/t/having-problem-with-socketexception-in-webgl-build/4783 "2023-12-22T07:41:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aliakbarm534](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/aliakbarm534/32/1716_2.png) [@aliakbarm534](https://forum.heroiclabs.com/u/aliakbarm534)\
**Post date:** [December 22, 2023, 7:41am UTC](https://forum.heroiclabs.com/t/having-problem-with-socketexception-in-webgl-build/4783/1 "2023-12-22T07:41:16Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/2X/a/ac95b0c54c4148487c012e8caac648940fe026e0.jpeg)  
So I have problem with this bug. Sometimes it’s connected to nakama sometimes not. I’ve handled them with try catch like this

```auto
public void SendChat(IChannel channel, string message)
{
    UnityDispatcher.Dispatch(async () =>
    {
        async UniTask SafeSendChat()
        {
            try
            {
                await _socket.WriteChatMessageAsync(channel, message);
            }
            catch (Exception e)
            {
                Debug.LogWarning(e);
                await UniTask.Delay(2000);
                SendChat(channel, message);
            }
        }

        await AuthenticateUser();
        await SafeSendChat();
    });
}

```

but the error still occur sometimes. Can you point me to where the function exactly to handle based on that pict?

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [December 22, 2023, 3:43pm UTC](https://forum.heroiclabs.com/t/having-problem-with-socketexception-in-webgl-build/4783/2 "2023-12-22T15:43:49Z")

</div>

Please share how you’re setting up the socket connection.
