I am using SRWebSocket to open a websocket connection in iOS. But if I am keeping the application idle for sometimes, the connection is closing automatically. After that when I am trying to send any data, the websocket connection is failing.
Is there anyway to keep the websocket connection alive, until I manually disconnect?
Web Socket gets disconnected when the app is kept idle or when the app goes in background. You can try using this:
[UIApplication sharedApplication].idleTimerDisabled = YES
Using this, will disable the provision of iPhone to be idle if your app is running.
We need to ping the server intermittently (In my case, I do this in every 30 seconds), for avoiding to close the connection from the server side.
Where, _webSocket is my SRWebSocket object, _timer is an object of NSTimer.