本文介绍了iPhone 应用程序进入网络请求永远不会完成的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 iPhone 应用每隔一段时间就会进入网络请求总是超时的状态,即使其他应用工作正常(甚至可以访问相同的站点).这与网络可用性的变化没有明显相关性,并且在 3G 和 WiFi 上都会发生.有关如何诊断问题的任何建议?

Every so often, my iPhone app gets into a state where network requests always time out, even if other apps work fine (and can even access the same sites). This isn't obviously correlated with changes in network availability, and happens both on 3G and over WiFi. Any suggestions on how to diagnose the problem?

(FWIW,该应用程序使用 MonoTouch 和 HttpWebRequest,但我怀疑出现问题的是较低级别的.)

(FWIW, the app uses MonoTouch and HttpWebRequest, but I suspect whatever's going wrong is lower-level.)

注意:通过后台应用程序和更改网络配置问题仍然存在;唯一的解决办法似乎是杀死应用程序并重新启动它.

Note: The problem persists through backgrounding the app and changing the network configuration; the only fix seems to be to kill the app and re-launch it.

更新:我曾尝试使用Reachability,但没有效果.Reachability.InternetConnectionStatus 总是返回 ReachableViaWiFiNetwork(或 ReachableViaCarrierDataNetwork,取决于;同样 IsHostReachable() 总是返回 true.Runtime.StartWWAN() 似乎没什么区别.

Updates: I've tried making use of Reachability, but to no effect. Reachability.InternetConnectionStatus always returns ReachableViaWiFiNetwork (or ReachableViaCarrierDataNetwork, depending; likewise IsHostReachable() always returns true. Runtime.StartWWAN() seems to make no difference.

推荐答案

https://bugzilla.novell.com/show_bug.cgi?id=555439 并且有几次尝试解决它.截至该错误的最后一条评论,它被假定已修复,但我想如果您使用的是 MonoTouch 4.0.3,那么有些情况无法解决.

There was a bug open about this at https://bugzilla.novell.com/show_bug.cgi?id=555439 and there were several attempts at resolving it. As of the last comment in the bug, it was presumed fixed but I guess if you are using MonoTouch 4.0.3 then there some cases that are not worked around.

基本上,该问题反映在另一个 Stackoverflow 问题中:iPhone 3G 连接启用

Basically, the problem is reflected in this other Stackoverflow question: iPhone 3G Connection Enabling

MonoTouch 尝试解决这个问题的方法是调用 MonoTouch.Runtime.StartWWAN(Uri),它使用 NSUrlConnection 打开一个到 uri 的虚拟连接以强制唤醒网络接口.然后,MonoTouch 返回到在 HttpWebRequest 中使用 BSD 套接字 API.

What MonoTouch does to try and work around this issue is to call MonoTouch.Runtime.StartWWAN(Uri) which opens a dummy connection to the uri using an NSUrlConnection to force-wake the network interface. Then, MonoTouch goes back to using the BSD socket API inside the HttpWebRequest.

这篇关于iPhone 应用程序进入网络请求永远不会完成的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 05:59