tcp连接状态

tcp的定时器timer: https://learningnetwork.cisco.com/thread/47664

tcp状态改变: http://ahuaxuan.iteye.com/blog/657511/
http://www.cnblogs.com/sunxucool/p/3449068.html

tcp关闭连接

这里写图片描述

MySQL timeout

mysql有两个timeout,一个是wait_timeout,一个是 interactive_timeout。分别对应交互式窗口(interactive_timeout),和非交互式窗口。在客户端没有请求,超过多长时间后,mysql服务器自动关闭连接。

设置超时时间为150秒:

mysql> show variables like '%timeout%';
+-----------------------------+----------+
| Variable_name               | Value    |
+-----------------------------+----------+
| connect_timeout             | 10       |
| delayed_insert_timeout      | 300      |
| innodb_flush_log_at_timeout | 1        |
| innodb_lock_wait_timeout    | 50       |
| innodb_rollback_on_timeout  | OFF      |
| interactive_timeout         | 150      |
| lock_wait_timeout           | 31536000 |
| net_read_timeout            | 30       |
| net_write_timeout           | 60       |
| rpl_stop_slave_timeout      | 31536000 |
| slave_net_timeout           | 3600     |
| wait_timeout                | 150      |
+-----------------------------+----------+
12 rows in set (0.00 sec)

具体的连接为:
这里写图片描述

图中倒数第5行,服务器3306端口开始主动关闭tcp连接.然后服务器进去FIN_WAIT2状态,然后经过tcp_fin_timeout时间后,服务端socket进入closed状态。

而客户端没有主动去调用socket.close,所以一直处于CLOSE_WAIT状态. 客户端tcp开启了keepalive功能,经过keepalive_idle_time时间后,发起keepalive probe探测包。然后服务器返回了一个RST tcp包,客户端才关闭连接。

此处(mac系统)

net.inet.tcp.keepidle: 600000

mac的单位是毫秒,此处设置的keepalive_idle_time是 10分钟,和wiresharek抓包结果一致。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章