最近做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. (单选后,显示相对应的div)点击免费没有变化,点击收费出现输入框

    <li> <label class="feiyonglabel">活动费用</label> <div class="textbo ...

  2. ipython notebook

    pip install jupyter和pip install "ipython[all]"

  3. AndrdoidStudio 2个jar包引起的异常Duplicate files copied in APK META-INF/LICENSE.txt

    在build.gradle中与compileSdkVersion **.buildToolsVersion “**.**.*"或defaultConfig 同级添加如下代码 packagin ...

  4. 在web.xml中配置error-page

    在web.xml中配置error-page 在web.xml中有两种配置error-page的方法,一是通过错误码来配置,而是通过异常的类型来配置,分别举例如下: 一.   通过错误码来配置error ...

  5. mysql中slow query log慢日志查询分析

    在mysql中slow query log是一个非常重要的功能,我们可以开启mysql的slow query log功能,这样就可以分析每条sql执行的状态与性能从而进行优化了. 一.慢查询日志 配置 ...

  6. 这个代码怎么改??Help快速排序 quicksort

    #include<stdio.h>int a[101],n;void quicksort(int left,int right){     int i,j,t,temp;     if(l ...

  7. SQL Server AlwaysOn articles

    Troubleshooting SQL Server AlwaysOn http://download.microsoft.com/download/0/F/B/0FBFAA46-2BFD-478F- ...

  8. .net 开源相关

    http://roslyn.codeplex.com/SourceControl/latest https://github.com/dotnet http://www.dotnetfoundatio ...

  9. Hadoop 安装记录

    第一步:打开/etc 下面的 profile文件,在其中加入环境变量设置的代码 done JAVA_HOME=/home/hadoop/installer/jdk7u65 PATH=$JAVA_HOM ...

  10. 使得<li>在一行显示,去除浮动的方法

    ①<li>使用浮动的方法,但是要用div包裹起来,该父元素需要设置宽度与高度: <!DOCTYPE html> <html> <head> <me ...