iPhone / iPad 应用程序间歇性出现“网络连接丢失”的情况错误
大家好,我为 iPhone / iPad 开发了一个应用程序。该应用程序定期进行 SOAP 调用来检索数据。目前我在应用程序的这一部分遇到了严重的问题。
为了获取数据,我使用了标准 SOAP 方法来连接到服务器,使用 NSURLConnection & NSMutableURLRequest。我已经实现了通常的代表......
- (void) connection: (NSURLConnection *) connection didReceiveResponse: (NSURLResponse *) response
{
}
- (void) connection: (NSURLConnection *) connection didReceiveData: (NSData *) data
{
}
- (void) connection: (NSURLConnection *) connection didFailWithError: (NSError *) error
{
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
}
这一切都很好......大多数时候。但是,如果应用程序进入睡眠模式并且我发起这些肥皂调用之一,我偶尔会(但对于客户端来说太频繁)返回两个错误之一。这些是...
错误域 = NSURLErrorDomainCode = -1005“网络连接丢失。” 或者 错误域=NSURLErrorDomainCode=-1001“请求超时。”
这让我发疯!
如果我启动立即刷新(调用完全相同的代码),则调用会成功。 所以基本上看来睡眠模式扰乱了无线连接 睡眠失败后的第一个 SOAP 调用。
有人见过这个吗?有解决办法吗?我在装有 Snow Leopard 的 MacBook 上使用 4.3 SDK 进行编码。
非常感谢对此的任何反馈。我在这个问题上花了好几天时间。
德里克.
Hi folks I have developed an app for the iPhone / iPad. This app makes regular SOAP calls to retrieve data. I'm having serious issues with this part of the app at the moment.
To get data i've used the standard SOAP method to connect to the server, using NSURLConnection & NSMutableURLRequest. I've implemented the usual delegates ...
- (void) connection: (NSURLConnection *) connection didReceiveResponse: (NSURLResponse *) response
{
}
- (void) connection: (NSURLConnection *) connection didReceiveData: (NSData *) data
{
}
- (void) connection: (NSURLConnection *) connection didFailWithError: (NSError *) error
{
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
}
This all works nicely ... most of the time. However if the app goes into sleep mode and I initiate one of these soap calls, I will occasionally (but too often for clients) get one of two errors returned. These are...
Error Domain=NSURLErrorDomainCode=-1005"The network connection was lost."
OR
Error Domain=NSURLErrorDomainCode=-1001"The request timed out."
This is driving me NUTS!!!
If I initiate an immediate refresh (calls the EXACT same code), the call then does succeed.
So basically it appears that the sleep mode is messing with the Wireless connection whereby
the first SOAP call after the sleep fails.
Has any one seen this? Is there a resolution? I've coded using 4.3 SDK on a MacBook with Snow Leopard.
Really appreciate any feedback on this. I've spent days on this one.
Derek.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您没有解决源问题,您可以尝试针对该特定错误重试一次,可能会延迟半秒。要强制执行一次重试,您可以保留一个重试计数,该计数会在成功发布后重置。
If you don't resolve the source issue, you could try retrying once on that specific error, perhaps with a delay of half a second. To enforce one retry, you could keep a retry count that is reset upon a successful post.