简体   繁体   English

Netty服务器挂起不接受任何连接

[英]Netty server hangs not accepting any connection

We've developed a Netty(3.5.11) based IM server that uses our custom protocol. 我们开发了一个基于Netty(3.5.11)的IM服务器,它使用我们的自定义协议。

The following is the order in which handlers are added to the pipeline. 以下是处理程序添加到管道的顺序。

objChannelPipeline.addLast("nettyLoggingHandler", objFrameworkLoggingHandler);
objChannelPipeline.addLast("ipFilter", objCustomIPFilterHandler);
objChannelPipeline.addLast("idleHandler", objIdleStateHandler);
objChannelPipeline.addLast("loggingHandler", objLoggingHandler);
objChannelPipeline.addLast("frameDecoder",objDelimiterBasedFrameDecoder);
objChannelPipeline.addLast("messageDecoder", new CustomProtocolDecoderHandler());
objChannelPipeline.addLast("groupOrder", executionHandler);
objChannelPipeline.addLast("ProtocolMultiplexer", objRegistrationHandler);

The "ProtocolMultiPlexer" handler is replaced with a suitable "ProtocolHandler" after we find the protocol from the register message that is obtained from the clients. 在我们从客户端获得的寄存器消息中找到协议之后,“ProtocolMultiPlexer”处理程序被替换为合适的“ProtocolHandler”。

The ipFilterHandler looks into a table in MYSQL database which contains blacklisted IP and decides if the connection from remote IP is to be processed or not. ipFilterHandler查看MYSQL数据库中的一个表,该表包含列入黑名单的IP,并决定是否要处理来自远程IP的连接。

Issue : After every few random number of days, the server stops processing any messages. 问题:每隔几天后,服务器就会停止处理任何消息。 We could recreate this issue by performing a load test and killing all the connections to the mysql server.When all the MYSQL processes where killed, all the netty threads except the boss thread seemed to be hung. 我们可以通过执行负载测试并终止与mysql服务器的所有连接来重新创建此问题。当所有MYSQL进程被杀死时,除了boss线程之外的所有netty线程似乎都挂起了。 The server was accepting connection requests but, further processing of messages where not taking place. 服务器正在接受连接请求,但是进一步处理没有发生的消息。 We thought that the issue was solved when we spotted that we had not added MYSQL "connectTimeout" and "socketTimeout" values. 当我们发现我们没有添加MYSQL“connectTimeout”和“socketTimeout”值时,我们认为问题已经解决了。 After adding these values and we tried again to repeat our test by killing all MYSQL process under load we did not find any threads entering hung state. 添加这些值之后我们再次尝试通过在加载时杀死所有MYSQL进程来重复我们的测试,我们没有发现任何线程进入挂起状态。

After deploying the server with the above changes in production, we encountered a similar error but this time, even the boss thread along with all other "Netty" threads have entered a hung state. 在生产中使用上述更改部署服务器之后,我们遇到了类似的错误,但这一次,即使老板线程与所有其他“Netty”线程一起进入挂起状态。 The only thread that is working is a cleaner thread from our DBPool( http://www.snaq.net/java/DBPool/ ). 唯一正在运行的线程是来自我们的DBPool( http://www.snaq.net/java/DBPool/ )的更干净的线程。 No Netty threads are logging anything and all the threads seemed to be hung. 没有Netty线程记录任何内容,所有线程似乎都挂起了。 I was not able to get thread dump. 我无法获得线程转储。 Any help is appreciable 任何帮助都很明显

Thanks 谢谢

Netty handlers are not supposed to perform long blocking operations like reading from a database. Netty处理程序不应该执行长时间的阻塞操作,例如从数据库读取。 Do it from a separate thread, as it is proposed in http://netty.io/4.0/guide/#faq.4 从单独的线程中进行,如http://netty.io/4.0/guide/#faq.4中提出的那样

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

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