java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)

Lain_ComeOn 2014-12-22 10:48:10


public static String doPost(String url,String execResult){
String result = "";
// 向服务器传送数据
HttpPost httpPost = new HttpPost(url);
// 先封装一个json对象
JSONObject param = new JSONObject();
List<NameValuePair> params = new ArrayList<NameValuePair>();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
String time = df.format(new Date());
params.add(new BasicNameValuePair("time",time));
params.add(new BasicNameValuePair("phone",EnterActivity.edit_phone.getText().toString()));
params.add(new BasicNameValuePair("model","自助排障"));
params.add(new BasicNameValuePair("op_type", FlowPanelActivity.flow_name));
params.add(new BasicNameValuePair("op_detail ", execResult));
params.add(new BasicNameValuePair("op_result","成功"));
// 绑定到entity
try {
StringEntity entity = new StringEntity(params.toString());
httpPost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse response = new DefaultHttpClient().execute(httpPost);
if (response.getStatusLine().getStatusCode() == 200) {
result = EntityUtils.toString(response.getEntity());
}
} catch (Exception e) {
result = "提交失败";
e.printStackTrace();
}
return result;
}


其他的都一切正常 就是response里面不执行 然后直接跳到了exception 显示异常

java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)。

求助!
...全文
565 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

790

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 其他移动相关
社区管理员
  • 移动开发其他问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧