简体   繁体   English

Windows Phone 7设备上的HTTP请求性能不佳

[英]Bad HTTP request performance on Windows Phone 7 device

I'm porting a game from Silverlight to Windows Phone 7 and using polling HTTP requests as my connection to the server. 我正在将游戏从Silverlight移植到Windows Phone 7,并使用轮询HTTP请求作为与服务器的连接。 It seems the performance of HTTP requests (either WebClient or HttpWebRequest) on device is extremely bad. 看来设备上HTTP请求(WebClient或HttpWebRequest)的性能非常差。 Emulator performs ok. 仿真器执行正常。

I've made a super-simple test program that continuously makes HTTP GET of a simple text/plain content. 我已经制作了一个超级简单的测试程序,该程序不断使简单的文本/纯内容进行HTTP GET。

Running the program on WP7 emulator gives me dozens of requests per second but on device (HTC HD7) only about 1/sec which is not good enough. 在WP7仿真器上运行该程序每秒可以发送数十个请求,但在设备(HTC HD7)上仅每秒约1个请求,这还不够好。 I've tried with GPRS and WLAN connection with similar results. 我尝试过GPRS和WLAN连接,但结果相似。 Also both WebClient and HttpWebRequest approaches give the same result. 同样,WebClient和HttpWebRequest方法都给出相同的结果。

To compare, an Android phone in the same networks performs much, much better. 相比之下,相同网络中的Android手机的性能要好得多。

Are there some known limitations in WP7 Silverlight network performance? WP7 Silverlight网络性能是否存在某些已知限制? Do they differ from device to device? 它们在设备之间是否有所不同? Are there any workarounds? 有什么解决方法吗?

This is a huge showstopper for my application. 这对于我的应用程序来说是一个巨大的突破。

EDIT: When the phone is connected to the PC, requests take ~40ms. 编辑:当电话连接到PC时,请求大约需要40毫秒。 When using GPRS/WLAN, requests take 500+ms. 使用GPRS / WLAN时,请求需要500毫秒以上的时间。 As mentioned, Android is super-fast without cable, probably around 50ms. 如前所述,Android无需电缆即可超快运行,大约需要50ms。

The problem lies in your network. 问题出在您的网络上。 Depending on the amounts of data and network speed (in your case - GPRS and WLAN), the performance indeed can vary drastically. 根据数据量和网络速度(在您的情况下为GPRS和WLAN),性能确实可能会发生巨大变化。 When the phone is connected through the USB, you are using the local Ethernet connection and that's why the performance is good. 通过USB连接电话时,您正在使用本地以太网连接,这就是为什么性能良好的原因。

To solve the problem, you need to: 要解决此问题,您需要:

a) make sure that the network is good. a)确保网络良好。 Don't try it on your app only. 不要只在您的应用上尝试。 See how other sites load, how other Internet-dependent applications perform. 查看其他网站如何加载,其他依赖Internet的应用程序如何执行。

b) re-model the way you are initiating HTTP requests. b)重新建模您发起HTTP请求的方式。 Try to reduce the frequency and (if possible) - amounts of transmitted data. 尝试降低频率和(如果可能)传输数据的数量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM