Failed to save Websocket in iOS background

I am building a VOIP application and also using the SocketRocket library to control my webcams and push data from it. But my main problem is when I click the (IOS) Home button, so my web site shuts down after one minute. I read the Apple documentation for developing a VOIP application from the link below

https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html

I also set UIBackgroundModes to plist for VOIP and Audio, but when I resume my application, therefore my websocket state is closed, although I do not release the websocket object.

_webSocket.readyState = 3 // It identifies that my websocket is close. 

Now, in order to reconnect to Websocket, I need to call websocket again and create another instance of the Websocket object after it was released earlier.

When websocket is closed, my SIP registration from my server is also disabled, and I need to connect to my SIP again.

How can I prevent my websocket from closing and how can I do setKeepAliveTimeout: handler: it is useful to fix my problem.

Using the library to create a websocket below

https://github.com/square/SocketRocket

+6
source share
1 answer

Try adding the following two lines to SRWebSocket _initializeStreams

 // Setup connections to be VOIP connections CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP); CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP); 
+3
source

Source: https://habr.com/ru/post/946340/


All Articles