timeout - integer containing number of milliseconds, controls two timeouts. Read timeout: Time to wait for a server to send response headers (and start the response body) before aborting the request. Connection timeout: Sets the socket to timeout after timeout milliseconds of inactivity. Note that increasing the timeout beyond the OS-wide TCP connection timeout will not have any effect (the default in Linux can be anywhere from 20-120 seconds)
该参数为设置了4秒。但是有些请求竟然1分15秒才返回。
curl对代理进行测试结果如下,由此可见timeout参数并没有生效。
1 2 3 4 5 6 7 8 9
time curl -vvv -x http://106.5.193.161:4245 baidu.com * Trying 106.5.193.161... * TCP_NODELAY set * Connection failed * connect to 106.5.193.161 port 4245 failed: Operation timed out * Failed to connect to 106.5.193.161 port 4245: Operation timed out * Closing connection 0 curl: (7) Failed to connect to 106.5.193.161 port 4245: Operation timed out curl -vvv -x http://106.5.193.161:4245 baidu.com 0.00s user 0.01s system 0% cpu 1:15.76 total