I am creating a VOIP application and also using a SocketRocket library to manage my Websockets and pull data from it. But my main problem is when I click on (IOS) Home button so my websocket disconnects after one minute. I have read Apple's documentation for developing VOIP application from the link below
https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html
I am also setting UIBackgroundModes in plist for VOIP and Audio, but when I resume my application so my websocket state is closed although I am not releasing websocket Object.
_webSocket.readyState = 3 // It identifies that my websocket is close.
Now for restablishing a connection with Websocket so I need to call again websocket open and create another instance of Websocket object after releasing previously.
On closing of websocket my SIP registeration from my server also disconnects and I need to reconnect to my SIP again.
How can I prevent my websocket to get close and how can I make setKeepAliveTimeout:handler: useful to fix my problem.
Library use to establish Websocket is as below
https://github.com/square/SocketRocket
Try adding the following two lines in SRWebSocket _initializeStreams
// Setup connections to be VOIP connections
CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With