VoIP应用程序无法在3G中保持连接

时间:2013-11-20 11:29:49

标签: ios sockets call voip 3g

目前我正在开发VoIP应用程序。在wifi连接让我完美。问题是当我使用3g时。在后台约6分钟后,VoIP套接字没有接到任何电话。但显然它是相互联系的。问题不是SIP服务器,因为这允许我在10分钟后续订注册。任何的想法? 感谢。

我添加代码:

AppDelegate *app = [[AppDelegate alloc] init];
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
int misocket = zObtenerSocket();

CFStreamCreatePairWithSocket(NULL, misocket, &readStream, &writeStream);
CFReadStreamSetProperty(readStream,   kCFStreamNetworkServiceType,kCFStreamNetworkServiceTypeVoIP);
CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);

inputStream = ( NSInputStream *)readStream;
outputStream = ( NSOutputStream *)writeStream;
[inputStream setDelegate:app];
[inputStream setProperty:NSStreamNetworkServiceTypeVoIP forKey:NSStreamNetworkServiceType];
[outputStream setDelegate:app];
[outputStream setProperty:NSStreamNetworkServiceTypeVoIP forKey:NSStreamNetworkServiceType] ;
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

[inputStream open];
[outputStream open];

[[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{
                                                               cierra_extra();
                                                               zbCerrar();
                                                               [inputStream close];
                                                               [outputStream close];
                                                               registrarse_bg();
                                                               }];

registrarse_bg()重新打开套接字并再次创建

0 个答案:

没有答案