简体   繁体   English

第二次读取时Netty http保持活动超时

[英]Netty http keep-alive timeout on second read

I am writing a webgame server using netty and intend to use keep-alive to have more performance. 我正在使用netty编写一个webgame服务器,并打算使用keep-alive来获得更高的性能。
If I use CachedThreadPool for boss and worker executor the server work fine for both keep-alive and non keep-alive connection. 如果我将CachedThreadPool用于boss和worker executor,那么服务器对keep-alive和non keep-alive连接都可以正常工作。
But if I use FixedThreadPool(1) one for boss and one for worker the first respond made it to the client but if browser use that connection to send second request it will blocked out and timeout at server, I close that connection and firefox open new socket, this socket also work fine at first respond.(I already include Connection Keep-alive and ContentLength to the respond header and double check it with httpAnalyzer tool. 但是如果我使用FixedThreadPool(1)一个用于老板而一个用于工作者,则第一个响应将其发送给客户端但是如果浏览器使用该连接发送第二个请求它将阻塞并在服务器超时,我关闭该连接并且firefox打开新的套接字,这个套接字在第一次响应时也可以正常工作。(我已经将Connection Keep-alive和ContentLength包含在响应头中,并使用httpAnalyzer工具仔细检查它。
So can someone please tell me why this happen and what is the best practice about using thread with netty for an webgame server. 那么有人可以告诉我为什么会发生这种情况,以及为we​​bgame服务器使用netty和netty的最佳做法是什么。 if netty is async this shouldn't be happen right ? 如果netty是异步的,这不应该发生吗?

You should always use a CachedThreadPool and use the constructor of NioSocketChannelFactory to limit the used threads. 您应该始终使用CachedThreadPool并使用NioSocketChannelFactory的构造函数来限制使用的线程。 I think its also documented in the javadocs. 我认为它也记录在javadoc中。

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

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