apache httpclient与close_wait
关键字: httpclient close_wait
最近做httpclient做转发服务,发现服务器上总是有很多close_wait状态的连接,而且这些连接都不会关闭,最后导致服务器没法建立新的网络连接,从而停止响应。
后来在网上搜索了一下,发现解决的方法也很简单,如果想重用连接,那就使用连接管理器,从连接管理器里获取连接,然后定时的用连接管理器来释放空闲连接。httpclient自带了SimpleHttpConnectionManager,提供了Java代码
closeIdleConnections(long idleTimeout)
closeIdleConnections(long idleTimeout) 这样的方法。
如果不需要重用链接,则直接在httpmethod创建时,设置一个http头信息就可以了
Java代码
httpmethod.setRequestHeader("Connection", "close");
httpmethod.setRequestHeader("Connection", "close");
这样就不会有恼人的close_wait了。
分享到:
相关推荐
使用JMeter压测时,报java.net.bindexception:address already is use:connect异常,可执行本资源的.bat文件,修改系统注册表。
jemeter 压测数据库 jemeter 是 Apache 组织基于 Java 开发的压力测试工具,用于对软件做压力测试。jemeter 最初被设计用于 Web 应用测试,但后来扩展到了其他测试领域,可用于测试静态和动态资源,如静态文件、...
当JMeter压测客户端出现"address already in use:connect"错误时,这通常是因为TCP连接资源耗尽。可以通过修改注册表来解决这个问题。在注册表编辑器中找到`\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\...
- **错误提示**:“Address already in use” 或 “Port 22: bind: Address already in use”。 - **原因**:另一个进程占用了SSH服务所需的端口。 - **解决方法**:更改SSH服务的监听端口,例如在 `/etc/ssh/...
An Internet Exchange Points (IXP) (typically in a standalone building with its own switches) is a meeting point where multiple ISPs can connect and/or peer together. An ISP earns its money by ...
vhost WARN 200 - _defaultVHost_Bind failed, try again ([any]:1935): java.net.BindException: Address already in use ``` **原因分析:** 该错误通常发生在同一台服务器上有多个WowzaMediaServer实例同时运行...
- **解决方案**: 检查SQL语句或PL/SQL块中的逻辑错误。 #### ORA-00037: Unable to switch between different transactions - **解释**: 无法在不同的事务之间切换。 - **解决方案**: 确认事务管理配置,并确保...
1. **java.net.BindException: Address already in use: JVM_Bind** 这个异常表明尝试绑定的端口已被其他服务占用。解决方法是检查并更改端口号,选择一个未被使用的端口。使用`netstat -an`命令可以帮助识别哪些...
#### WSAEADDRINUSE (10048): Address already in use. - **含义**:当试图绑定一个已经被其他套接字占用的地址(协议/ IP 地址/ 端口号)时,会引发此错误。这种情况下,地址被认为是被独占使用的。 - **解决方案*...
java.net.BindException: Address already in use 该异常发生在服务器端进行 new ServerSocket(port) 操作时,原因是因为与 port 相同的端口已经被占用,解决方法是找到一个空闲的端口。 java.net....
java.net.BindException: Address already in use: JVM_Bind 当尝试通过`new ServerSocket(port)`创建一个服务器套接字,并指定端口号`port`(该值应在0到65536之间)时,如果出现此异常,表明所指定的端口已被...
- The information field "Device in use" has been added to the device statistic display. This shows which device (primary or backup-device) is currently active. This state can also be requested via...
- Developing the students' abstract thinking skills since they may struggle to connect new information to what they already know. Part 4: Teaching Methods To address the challenges and achieve the ...
your program to use IMAP instead of POP and expect everything in IMAP to be supported. Assuming your mail server supports IMAP, your JavaMail-based program can take Fundamentals of the JavaMail API...
Is this interface in use? [yes]: 2) 是否设置此接口的IP参数: Configure IP on this interface? [yes]: 3) 设置接口的IP地址: IP address for this interface: 192.168.162.2 4) 设置接口的IP子网掩码: ...
在本例中,它可能被用来启用SO_REUSEADDR选项,解决“Address already in use”错误。这个选项允许我们在服务器关闭后立即重启,并重新绑定到之前使用的同一端口。通常,当一个TCP连接被终止,操作系统会在一段时间...
DLL: JTAG: When only having 1 TAP in the JTAG chain and its matches the one for the configured CPU core but the TAP-ID was unknown, connect did not work. Fixed. DLL: Linux: Delayed / slowed execution ...
The checking part of the app will always be free here but because of the time it took me to universally code the removal and because we already have documented 100000 ways to do it yourself (see post...
In the Connect to box, click Connect to .... In the Open Web Site dialog box, click the FTP Sites tab. Type the FTP address of your server, and if required, the user name and password that your ...