java.net.SocketException:软件导致连接中止:recv 失败 [英] java.net.SocketException: Software caused connection abort: recv failed

查看:40
本文介绍了java.net.SocketException:软件导致连接中止:recv 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于以下错误的确切含义,我无法找到合适的答案:

I haven't been able to find an adequate answer to what exactly the following error means:

java.net.SocketException:软件导致连接中止:recv 失败

注意事项:

  • 此错误不常见且不可预测;尽管收到此错误意味着以后对 URI 的所有请求也将失败.
  • 唯一有效的解决方案(也只是偶尔)是重新启动 Tomcat 和/或实际机器(在本例中为 Windows).
  • URI 肯定是可用的(通过要求浏览器执行获取来确认).

相关代码:

BufferedReader reader;
try { 
 URL url = new URL(URI);
 reader = new BufferedReader(new InputStreamReader(url.openStream())));
} catch( MalformedURLException e ) { 
 throw new IOException("Expecting a well-formed URL: " + e); 
}//end try: Have a stream

String buffer;
StringBuilder result = new StringBuilder();
while( null != (buffer = reader.readLine()) ) { 
 result.append(buffer); 
}//end while: Got the contents.
reader.close();

推荐答案

这通常意味着存在网络错误,例如 TCP 超时.我会首先在连接上放置一个嗅探器(wireshark),看看你是否能发现任何问题.如果存在 TCP 错误,您应该能够看到它.此外,您可以检查路由器日志(如果适用).如果在任何地方都涉及无线,那是此类错误的另一个来源.

This usually means that there was a network error, such as a TCP timeout. I would start by placing a sniffer (wireshark) on the connection to see if you can see any problems. If there is a TCP error, you should be able to see it. Also, you can check your router logs, if this is applicable. If wireless is involved anywhere, that is another source for these kind of errors.

这篇关于java.net.SocketException:软件导致连接中止:recv 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆