最近做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的更多相关文章

  1. java.net.SocketException:Software caused connection abort: recv failed 异常分析 +socket客户端&服务端代码

    java.net.SocketException:Software caused connection abort: recv failed 异常分析 分类: 很多的技术 2012-01-04 12: ...

  2. FTP上传文件,报错java.net.SocketException: Software caused connection abort: recv failed

    FTP上传功能,使用之前写的代码,一直上传都没有问题,今天突然报这个错误: java.net.SocketException: Software caused connection abort: re ...

  3. 报错java.net.SocketException: Software caused connection abort: recv failed 怎么办

    产生这个异常的原因有多种方面,单就如 Software caused 所示, 是由于程序编写的问题,而不是网络的问题引起的. 已知会导致这种异常的一个场景如下: 客户端和服务端建立tcp的短连接,每次 ...

  4. Software caused connection abort: recv failed 错误介绍

    解决1: Software caused connection abort: recv failed java.net.SocketException: Software caused connect ...

  5. java.net.SocketException: Software caused connection abort: socket write error

    用Java客户端程序访问Java Web服务器时出错: java.net.SocketException: Software caused connection abort: socket write ...

  6. testNG java.net.SocketException: Software caused connection abort: socket write error

    执行用例报错,提示 java.net.SocketException: Software caused connection abort: socket write error java.net.So ...

  7. 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 ...

  8. ClientAbortException: java.net.SocketException: Software caused connection abort: socket write erro

    1.错误描述 ClientAbortException: java.net.SocketException: Software caused connection abort: socket writ ...

  9. jmeter压测tcp协议接口:java.net.SocketException: Software caused connection abort: socket write error

    tcp接口,试压过程中,部分请求报如下错误: java.net.SocketException: Software caused connection abort: socket write erro ...

随机推荐

  1. webStorm快捷键总结

    Ctrl+Shift+a:快速查找使用编辑器所有功能1.左侧栏目录显影:Ctrl+Shift+F122.文件模板配置:File>Settings>Editor>File and Co ...

  2. C++ Primer : 第九章 : vector变长、string的其他操作以及容器适配器

    vector变长机制.string的其他构造方法,添加.替换和搜索操作,string比较和数值转换,最后是容器适配器. vector对象是如何增长的 vector和string类型提供了一些成员函数, ...

  3. Javascript对象属性与方法汇总

    Javascript对象属性与方法汇总 发布时间:2015-03-06 编辑:www.jquerycn.cn 详细介绍下,javascript对象属性与对象方法的相关知识,包括javascript字符 ...

  4. poj3553 拓扑序+排序贪心

    题意:有多个任务,每个任务有需要花费的时间和最后期限,任务之间也有一些先后关系,必须先完成某个才能开始某个,对于每个任务,如果没有越期,则超时为0,否则超时为结束时间-最后期限,求总超时时间最小的任务 ...

  5. kuangbin_ShortPath A (POJ 2387)

    最短路模板题 但是其实很费时间 因为要看明白dij floyd 以及 dij优化 spfa优化 交了三次 大概是理解了 不过涉及到priority_queue的重载运算符问题 以后要在C++里面好好看 ...

  6. some knowledge of maven {maven实战}

    maven是跨平台的,不仅是一个构建工具,也是一个可以管理依赖的工具.它最大化的消除了构件的重复,并且提供了中央仓库,能帮我们自动下载构件.------------------------------ ...

  7. 黑马程序员——JAVA基础之简述 类的封装

    ------- android培训.java培训.期待与您交流! ---------- 类的封装(Encapsulation)  封装:是指隐藏对象的属性和实现细节,仅对外提供公共访问方式. 封装优 ...

  8. (转)A Beginner's Guide To Understanding Convolutional Neural Networks

    Adit Deshpande CS Undergrad at UCLA ('19) Blog About A Beginner's Guide To Understanding Convolution ...

  9. weblogic管理1——创建 和 删除一个domain

    说明本文环境  WLS_HOME=/home/weblogic/Oracle/Middleware创建一个domian   第一种方法通过console 创建>[weblogic@11g Mid ...

  10. html dl dt dd标签元素语法结构与使用

    dl dt dd认识及dl dt dd使用方法 <dl> 标签用于定义列表类型标签. dl dt dd目录 dl dt dd介绍 结构语法 dl dt dd案例 dl dt dd总结 一. ...