如何在KTOR(NetTy)的服务器端设置静止超时

发布于 2025-02-07 13:51:02 字数 607 浏览 2 评论 0原文

据我了解, keep-alive超时是服务器端属性。我想在KTOR中配置Keep-Alive超时。这是服务器:

embeddedServer(Netty, port = 8080, configure = {..}, ) { ... }

我看到netty特定配置中的布尔tcpkeepalive属性。它的定义是:

如果设置为true,请启用TCP保持活力以进行连接,以便所有死亡 客户连接将被丢弃。超时时间已配置 通过系统,请相应地配置主机。

因此,对我而言,尚不清楚这意味着相应地配置您的主机。

我找到了这个答案 https:https:// /stackoverflow.com/a/29749938/3601615 可以告诉您如何关闭空闲连接。但是我一直认为,使用一些单个属性来设置静止超时是足够的,并且提到的解决方案看起来很复杂。

我将感谢任何建议如何在KTOR中配置保持活力的超时。

As I understand keep-alive timeout is a server side property. I would like to configure keep-alive timeout in ktor. Here is the server:

embeddedServer(Netty, port = 8080, configure = {..}, ) { ... }

I see boolean tcpKeepAlive property inside Netty specific configuration. And it definition is:

If set to true, enables TCP keep alive for connections so all dead
client connections will be discarded. The timeout period is configured
by the system so configure your host accordingly.

So for me it is not clear what does it mean configure your host accordingly.

I found this answer https://stackoverflow.com/a/29749938/3601615 which could tell how to close idle connections. But I have been supposing that it would be enough to use some single property to set keep-alive timeout, and the mentioned solution looks complicated.

I will appreciate any advices how to configure keep-alive timeout in ktor.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文