# iOS socket disconnected event

**URL:** <https://forum.heroiclabs.com/t/ios-socket-disconnected-event/2566>\
**Category:** Client Libraries\
**Tags:** sdk-unity\
**Created:** [April 27, 2022, 10:01am UTC](https://forum.heroiclabs.com/t/ios-socket-disconnected-event/2566 "2022-04-27T10:01:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahamed](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/ahamed/32/1094_2.png) [@ahamed](https://forum.heroiclabs.com/u/ahamed)\
**Post date:** [April 27, 2022, 10:01am UTC](https://forum.heroiclabs.com/t/ios-socket-disconnected-event/2566/1 "2022-04-27T10:01:56Z")

</div>

Hi Everyone!

We are facing a weird issue in iOS. We subscribed to the **\_socket.Closed** event to detect socket disconnect issue and try to reconnect using a new socket.

While trying this on an android phone, we are getting the event called immediately. But for iOS, it’s taking time to fire the event when I turn off the wifi of an iOS device, like 30/40 seconds.

Is it expected?

```auto
_socket.Closed += InternetConnectivity.OnSocketClosed;

```

1. Nakama: Nakama: **3.1.2**
2. Server Framework Runtime language: **Lua**
3. Unity SDK: **2.8.1**

---

<div class="post-metadata">

**Author:** ![sean](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sean/32/643_2.png) [@sean](https://forum.heroiclabs.com/u/sean)\
**Post date:** [April 27, 2022, 2:25pm UTC](https://forum.heroiclabs.com/t/ios-socket-disconnected-event/2566/2 "2022-04-27T14:25:06Z")

</div>

Hi Foysal,

Welcome to the Heroic Labs community and thank you for sharing that you are working with Nakama.

Socket timeouts are dependant on the client’s underlying socket usage so they may differ between platforms and versions.

You can set the default timeout in Nakama for Unity in a couple of ways:

When [connecting a socket](https://dotnet.docs.heroiclabs.com/html/class_nakama_1_1_socket.html#a11620a9e6706ddaf48d260d56c7cdcaa) you can specify the timeout. You will need to create the socket first.

Or passing an existing ISocketAdaptor instance with timeout configured to the [Socket.From](https://dotnet.docs.heroiclabs.com/html/class_nakama_1_1_socket.html#ac4201f5bdda381252451e4aef465b498) method.

Additionally, you can configure the [server socket ping and pong timeout](https://heroiclabs.com/docs/nakama/getting-started/configuration/#socket).

With a combination of configuring the server and client you should be able to detect timeouts closer to when they occur. It will unfortunately never be accurate to the millisecond as timeout events are always reliant on underlying ping/pong messages and reasonable allowances for hiccups in the connection.

Kind regards,  
Sean
