java.net.SocketException: Software caused connecti

2019-01-04 10:25发布

This question already has an answer here:

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

java.net.SocketException: Software caused connection abort: recv failed

Notes:

  • This error is infrequent and unpredictable; although getting this error means that all future requests for URIs will also fail.
  • The only solution that works (also, only occasionally) is to reboot Tomcat and/or the actual machine (Windows in this case).
  • The URI is definitely available (as confirmed by asking the browser to do the fetch).

Relevant code:

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();

标签: java sockets
10条回答
不美不萌又怎样
2楼-- · 2019-01-04 11:12

If you are using Netbeans to manage Tomcat, try to disable HTTP monitor in Tools - Servers

查看更多
霸刀☆藐视天下
3楼-- · 2019-01-04 11:14

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.

查看更多
戒情不戒烟
4楼-- · 2019-01-04 11:14

Look if you have another service or program running on the http port. It happened to me when I tried to use the port and it was taken by another program.

查看更多
【Aperson】
5楼-- · 2019-01-04 11:25

Try adding 'autoReconnect=true' to the jdbc connection string

查看更多
登录 后发表回答