Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Managing server's HTTP keep-alive timeout with Netty

I am running an application server using the Play! Framework, which uses Netty for the actual IO heavy lifting.

The HTTP connections have keep-alive turned on (which is the default for HTTP 1.1), and I'm happy with this. However, I would like these kept-alive connections to time out after a certain amount of inactivity (e.g. 15 seconds). As I understand it, this would involve the server closing the connection actively.

This seems like a standard config option, and indeed there is such a setting for Apache. However, I can't see any way to do this in Netty/Play. It seems like the connections stay open until either the client closes them, or the socket times out at the OS level (about two hours).

Is this functionality supported out of the box? And if not, is it feasible to implement by hand (in particular, how do I know when a Channel was last used, or even if it's in use right now)?

like image 680
Andrzej Doyle Avatar asked Nov 28 '25 16:11

Andrzej Doyle


1 Answers

You can put IdleStateHandler in the application pipeline.

like image 198
jdb Avatar answered Dec 01 '25 06:12

jdb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!