-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
请问http长连接如何复用? #198
Comments
没有道理啊,连接复用非常智能的,每个请求都建立连接是不是对方主动关闭了连接? |
我又测试了一下,以下是一个简单的总结: 前提:访问不同url(服务器地址相同),不设置connection字段 |
我理解的复用是同一个地址的请求,都应该复用,无论我是在哪个线程发起的请求,但根据测试结果来看,在回调线程中发起下一个请求才是复用的。 |
噢噢,连接复用的原理是有空闲连接就复用,如果没有空闲连接而且并发连接数没有超过最大值(默认200),则发起新连接;达到最大值,则得到EAGAIN错误。你的第一个case是100个请求同时发起,那么很大概率上是并发请求,所以没有办法复用连接。 |
测了一下,确实是这样,感谢! @Barenboim |
除了头Connection字段,还有什么点需要处理呢?抓包发现基本上每个请求都建立了连接。
The text was updated successfully, but these errors were encountered: