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.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 并且有几次尝试解决它。​​截至该bug的最后评论,它是推测是固定的,但我想如果你使用的是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.

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

Basically, the problem is reflected in this other * 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.