httpclient操作引发Too many open files

简介:

来自:http://www.54chen.com/java-ee/java-httpclient-too-many-open-files.html


实际上,HttpClient建立Socket时 ,post.releaseConnection()并没有真正关闭连接,而是将该连接提交给 MultiThreadedHttpConnectionManager,等待复用。
而http的连接是等待timeout才会自动断开的,所以,当用完系统的句柄后,自然会报Too many open files
解决办法:
设置post方法的header,增加红色字体部分的配置:
HttpClient client = new HttpClient();
    client.getParams().setBooleanParameter(
     "http.protocol.expect-continue", false);

   PostMethod method = new PostMethod(url);
    method.addRequestHeader("Connection", "close");
 
相关文章
|
8月前
|
Java
cannot open shared object file: No such file or directory
cannot open shared object file: No such file or directory
99 0
|
JavaScript
Error: EMFILE: too many open files, watch 报错的解决方法
Error: EMFILE: too many open files, watch 报错的解决方法
750 1
|
Linux 开发工具
Too many open files 解决办法
还在等什么,快来一起讨论关注吧,公众号【八点半技术站】,欢迎加入社群
|
前端开发 API
file_get_contents遍历api数据
file_get_contents遍历api数据
151 0
file_get_contents遍历api数据
|
安全 NoSQL 开发者
Open Source v.s. Open Core
本文主要介绍 Open Source 和 Open Core 的区别。Open Source 已广为人知,那么 Open Core 又是什么,在开源软件盛行的今天,二者会怎样影响这个市场呢
1281 0
|
Java Linux
too many open files
If you encounter the file descriptor leaks problem, it might be helpful to you.
2541 0