热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

想要改变TCP关闭超时-wanttochangeTCPclosingtimeout

Wehaveaclientserverapplicationinuseonoursuselinuxserver.Sometimesithappens,thatont

We have a client server application in use on our suse linux server.
Sometimes it happens, that on the client side the tcp socket somehow goes away and on the server side the other end of the socket remains existent.

我们在suse linux服务器上使用了一个客户端服务器应用程序。有时它会发生,在客户端,tcp套接字会以某种方式消失,而在服务器端,套接字的另一端仍然存在。

At the end of the day, when we stop the backend on the linux server, the backend tries to close all remaining tcp connections, also those "zombie" sockets.

在一天结束时,当我们停止linux服务器上的后端时,后端会尝试关闭所有剩余的tcp连接,也就是那些“僵尸”套接字。

(I watch this with strace).

(我用strace看这个)。

When the backend tries to close a tcp connection, where there is nothing anymore on the client side, it sends a [FIN, ACK] packet to the target. And of course, nothing comes back.

当后端尝试关闭tcp连接时,客户端不再存在任何内容,它会向目标发送[FIN,ACK]数据包。当然,什么也没有回来。

The backend repeats to send this packet. The first time it waits only a few hundredths of a second to repeat it, then, it waits longer and longer. At the end it waits seconds to repeat it. But, after 15 seconds, there is a timeout, and it goes on to end another tcp connection.

后端重复发送此数据包。它第一次只等几百分之一秒重复它,然后,它等待的时间越来越长。最后它等待几秒钟重复它。但是,15秒后,有一个超时,它继续结束另一个TCP连接。

Now, I do not know where this 15 second timeout is coming from. I would like to change it.

现在,我不知道这15秒超时的来源。我想改变它。

Thank you very much in advance.

非常感谢你提前。

1 个解决方案

#1


1  

I think you may have two problems.

我想你可能有两个问题。

  • You should detect the client disconnecting and close the server's end of the socket so you free that resources ASAP. You may set a timeout yourself for connections with no activity in the application layer. Read this.
  • 您应该检测到客户端断开连接并关闭服务器端口的套接字,以便尽快释放该资源。您可以自己为应用程序层中没有活动的连接设置超时。读这个。
  • If you cannot handle that "zombie" sockets in the app layer you may change the timeout in the SO. Read this.
  • 如果您无法在应用层中处理“僵尸”套接字,则可以更改SO中的超时。读这个。

推荐阅读
author-avatar
runyuantezhong773
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有