The socket closes after 3 minutes after putting the application in the background

119 views Asked by At

I am using "GCDAsyncSocket" in my project. My project A video conversation project using the Linphone library. And I also use socket connection. The application only works between devices connected to the local modem.

The socket I use in my application closes 3 minutes after entering the application background. I want the socket not to close as long as the application is running (unless the application is killed). My application doesn't have a backend. All communication, except for Linphone, only takes place via the socket.

How can I do that?

I've tried

func socket(_ sock: GCDAsyncSocket, didAcceptNewSocket newSocket: GCDAsyncSocket) {
    print("connect succuess")
    print("connect to" + newSocket.connectedHost!)
    print("port" + String(newSocket.connectedPort))
    clients.append(newSocket)
    callIP = newSocket.connectedHost!
    sock.enableBackgroundingOnSocket()

    newSocket.readData(withTimeout: -1, tag: 0)
}
0

There are 0 answers