HttpUrlConnection java.net.SocketException: Software caused connection abort: recv failed
最近做java swing程序在模拟httprequest请求的时候出现了这个错误
java.net.SocketException: Software caused connection abort: recv failed
显示是在connection在获得con.getInputStream()时随机出现这个exception,
最后我感觉是 16行把输出流关闭了,这个时候server会认为连接已断开,于是该把16行放到27行,不知道对不对。
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod(requestMethod);
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(true);
con.setRequestProperty("Content-Type", contentType);
con.setRequestProperty("Accept-Charset", charset); DataOutputStream printout = new DataOutputStream(con.getOutputStream()); // This is the POST
// String content = "type=ask_bid_list_table&symbol="+coinName+"_cny"; printout.writeBytes(content);
printout.flush();
printout.close();
if (con.getResponseCode() == 200) {
BufferedReader input = new BufferedReader(new InputStreamReader(
con.getInputStream(), charset));
String str;
StringBuilder sb = new StringBuilder();
// Read the response while (null != ((str = input.readLine()))) {
sb.append(str);
} input.close();
}
这个错误只是随机出现。
HttpUrlConnection java.net.SocketException: Software caused connection abort: recv failed的更多相关文章
- java.net.SocketException:Software caused connection abort: recv failed 异常分析 +socket客户端&服务端代码
java.net.SocketException:Software caused connection abort: recv failed 异常分析 分类: 很多的技术 2012-01-04 12: ...
- FTP上传文件,报错java.net.SocketException: Software caused connection abort: recv failed
FTP上传功能,使用之前写的代码,一直上传都没有问题,今天突然报这个错误: java.net.SocketException: Software caused connection abort: re ...
- 报错java.net.SocketException: Software caused connection abort: recv failed 怎么办
产生这个异常的原因有多种方面,单就如 Software caused 所示, 是由于程序编写的问题,而不是网络的问题引起的. 已知会导致这种异常的一个场景如下: 客户端和服务端建立tcp的短连接,每次 ...
- Software caused connection abort: recv failed 错误介绍
解决1: Software caused connection abort: recv failed java.net.SocketException: Software caused connect ...
- java.net.SocketException: Software caused connection abort: socket write error
用Java客户端程序访问Java Web服务器时出错: java.net.SocketException: Software caused connection abort: socket write ...
- testNG java.net.SocketException: Software caused connection abort: socket write error
执行用例报错,提示 java.net.SocketException: Software caused connection abort: socket write error java.net.So ...
- Caused by: java.net.SocketException: Software caused connection abort: socket write error
1.错误描述 [ERROR:]2015-05-06 10:54:18,967 [异常拦截] ClientAbortException: java.net.SocketException: Softwa ...
- ClientAbortException: java.net.SocketException: Software caused connection abort: socket write erro
1.错误描述 ClientAbortException: java.net.SocketException: Software caused connection abort: socket writ ...
- jmeter压测tcp协议接口:java.net.SocketException: Software caused connection abort: socket write error
tcp接口,试压过程中,部分请求报如下错误: java.net.SocketException: Software caused connection abort: socket write erro ...
随机推荐
- URAL 1242 Werewolf(DFS)
Werewolf Time limit: 1.0 secondMemory limit: 64 MB Knife. Moonlit night. Rotten stump with a short b ...
- AJAX保留浏览历史的解决方案——hashchange()
在ajax请求中,不能更新地址栏,地址栏上的“前进”和“后退”按钮就失效了,带来了另外一种糟糕的用户体验. 解决方案如下: 方案一:使用window. Onhashchange 事件 如下面Html片 ...
- install gcc under suse
SUSE 11中安装GCC开发环境 SUSE11中安装GCC开发环境 安装包下载网站:http://213.174.32.130/sles/distribution/11.0-SP1/repo/dis ...
- CSS 通用原子类
/*文字排版*/.f10 { font-size: 10px; }.f11 { font-size: 11px; }.f12 { font-size: 12px; }.f13 { font-size: ...
- spring源码学习之【准备】cglib动态代理例子
一:委托者 package com.yeepay.porxy.cglib.test; import java.util.HashMap; import java.util.Map; /** * 目标类 ...
- sersync2 实时同步配置
在同步服务器上开启sersync,将监控路径中的文件同步到目标服务器,因此需要在同步服务器配置sersync,在同步目标服务器配置rsync. 一.同步目标服务器配置rsync # rpm -qa | ...
- Js文本溢出自动添加省略号ellipsis
原文: ellipsis: function(value, len, word) { //判断value有没有超过指定长度 if (value && v ...
- Python列表操作——模拟实现栈和队列
1.实现栈: stack=[] def pushit(): stack.append(raw_input('Enter New String:').strip()) def popit(): if l ...
- 06-Java 本地文件操作
1.File类简介 创建好:File file=new File("hello.txt"); 后,按住Ctrl键.单击File.会出现File的源代码. 在视图左下角双击" ...
- linux包之包管理命令rpm-yum
背景 YUM(Yellow dog Updater, Modified)为多个Linux发行版的前端软件包管理器,例如 Redhat RHEL, CentOS & Fedora. YUM通过调 ...