iOS不会使用http keep-alive。极高的延迟 [英] iOS doesn't to use http keep-alive. Very high latency

查看:660
本文介绍了iOS不会使用http keep-alive。极高的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试服务器的延迟,因此我发送了一个休息请求。
使用rest api客户端,我从桌面获得了大约500毫秒的延迟,但是当我在iOS Simulator上执行相同的请求(使用AFNetworking)时,我得到了1.8秒的延迟。

I wanted to test latency for my server, so I sent a rest request. Using a rest api client, i got around 500 ms latency from desktop, but when i do the same request on iOS Simulator (using AFNetworking) , I am getting latency of 1.8 seconds.

我的服务器发送keep alive标头,我注意到PC发出的第一个请求的延迟与IOS相似。
如何使iOS荣誉保持活力或减少延迟?
由于我正在制作实时应用程序,因此必须具有低延迟。在同一台计算机上,我的其余客户端比iOS快约3倍。我该如何解决这个问题?

My server sends keep alive headers, and I noticed that the first request from my PC is of a similar latency as IOS. How do I make iOS honour keep alive , or reduce latency ? Since I am making a realtime app , it is a must that I have low latency. From the same computer , my rest client is about 3x faster than iOS. How may I fix this issue ?

编辑::
我注意到从服务器禁用https支持后,延迟变为1秒。对我来说,很明显,iOS不使用keep alive存在一些问题。

: I noticed that upon disabling https support from my server, the latency becomes 1 second. To me it is quite obvious that there is some problem with iOS not using keep alive.

我使用wireshark监视了网络活动。下面是每隔1秒左右发出的两个http请求的图片:

I monitored network activity using wireshark. Below is a picture of two http requests made at around 1 second intervals:

可以看到加密的握手进行了两次。

It can be seen that encrypted handshake is being done twice.

使用我的其余客户端,这就是相同的http每隔2秒发出一次请求的样子:

Using my rest client, this is it what the same http requests at 2 second interval looks like:

推荐答案

如果看不到任何代码,就很难确定发生了什么,但请确保:

Without seeing any code, it's hard to say for sure what's happening, but make sure:


  • 请求在同一会话中。每个会话使用单独的基础连接,因此如果会话消失,连接也将使用。

  • 请求使用相同的身份验证凭据(如果适用)。

另外,尝试启用 HTTPShouldUsePipelining 。如果同一服务器上有多个请求正在运行,则直到(至少)最后一个连接到达时,连接才会关闭,因此即使操作系统正在积极地管理电源,有时这也可能有所帮助。

Additionally, try enabling HTTPShouldUsePipelining. If there are multiple requests in flight for the same server, the connection won't be closed until (at least) the last one arrives, so that might sometimes help even when the OS is aggressively managing power.

这篇关于iOS不会使用http keep-alive。极高的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆