源码来自 https请求
1、连接超时
//连接超时
HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 10000);
2、关闭client连接
httpClient.getConnectionManager().closeIdleConnections(0, TimeUnit.SECONDS);
测试:
win10环境,输入查看命令 netstat -n
测试步骤:(不关闭)
1、netstat -n 查看<外部地址>(就是https请求的地址)
2、发送https请求,在不写关闭的情况
3、再次查询netstat -n ,发现<外部地址>(https请求地址)存活
测试步骤:(关闭)
1、netstat -n 查看<外部地址>(就是https请求的地址)
2、发送https请求,关闭的情况
3、再次查询netstat -n ,发现<外部地址>(https请求地址)不存活