Note that there are some explanatory texts on larger screens.

plurals
  1. POVoIP socket on iOS - no notifications received
    primarykey
    data
    text
    <p>I have a VoIP app that uses a TCP service to wake it up on incoming calls. The TCP socket is created with this code fragment:</p> <pre><code>CFReadStreamRef read = NULL; CFWriteStreamRef write = NULL; ... CFStreamCreatePairWithSocketToHost(NULL,(__bridge CFStringRef)shost, port, &amp;read, &amp;write); self.read = (__bridge NSInputStream*)read; self.write = (__bridge NSOutputStream*)write; if (![self.read setProperty:NSStreamNetworkServiceTypeVoIP forKey:NSStreamNetworkServiceType]){ [Log log:@"Could not set VoIP mode to read stream"]; } if (![self.write setProperty:NSStreamNetworkServiceTypeVoIP forKey:NSStreamNetworkServiceType]){ [Log log:@"Could not set VoIP mode to write stream"]; } self.read.delegate = self; self.write.delegate = self; CFRelease(read); CFRelease(write); [self.read scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [self.write scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [self.read open]; [self.write open]; </code></pre> <p>I've also set the following:</p> <ol> <li>VoIP &amp; Audio in the info plist</li> <li>Keep alive timer using [UIApplication sharedApplication] setKeepAliveTimeout</li> <li>UIRequiresPersistentWiFi = YES in the info plist (quite sure it's not required, but...)</li> </ol> <p>This works well while the app is in the foreground, and even works well in the background for a few minutes, but after a few minutes - the app does not receive any new TCP messages. It doesn't work on wifi or 3G, same result for both.</p> <p>I also tried setting the property just to the read stream (though the read and write point to the same socket). Whenever I receive data on the TCP or send data I also start a short background task. BTW - everything takes place on the main thread.<br/> I've checked if the app crashes - it doesn't.<br/> The same behavior can be observed while debugging on the device - after a while - nothing is received (no crashes, warnings, anything).</p> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload