简体   繁体   中英

Java error - Software caused connection abort: recv failed

The full error is:

java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:168)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.BufferedReader.fill(BufferedReader.java:154)
    at java.io.BufferedReader.readLine(BufferedReader.java:317)
    at java.io.BufferedReader.readLine(BufferedReader.java:382)
    at chat.run(chat.java:76)
    at java.lang.Thread.run(Thread.java:722)

"at chat.run(chat.java:76)" is this line:

System.out.println("[_in_"+(line=ins.readLine())+"_]");

line being a string and ins being a BufferedReader

ins = new BufferedReader(new InputStreamReader(_sock.getInputStream()));

_sock being

Socket       _sock      = null;
_sock = serv_sock.accept();

This happends on my Server java and not on my client java... Also, this happends when I dont send anything for a little while

-----EDIT------

I tried it again; First it went 40 minutes of doing nothing and it still worked, then I waited 40 minutes again and this time it didn't work.

It seems to be kind of random.. I can't figure out what's causing it.

The files I have are * [client.java], [chat.java], [vlc.java] * [server.java], [chat.java], [vlc.java]

the vlc files are the same in both although chat is different (since I havn't done Threads in both client and server yet)

Here's the code;

   SERVER
server.java: pastebin.com/GH8ShcGp
chat.java  : pastebin.com/iaL23kSb
vlc.java   : pastebin.com/9kyrbh5q



    CLIENT
client.java: pastebin.com/HDK450Jg
chat.java  : pastebin.com/CfHrEUkE
vlc.java   : pastebin.com/SfZgYy58

I think it's a window/network thing. Someone who please can help me fix this??

I couldn't get your exact problem to replicate on my own computer using your code and localhost-connections, but after reading about "BufferedReader.readLine() throwing java.net.SocketException: Software caused connection abort: recv failed" in several different pages, I believe this is related to your network. The connection seems to be terminated due to TCP timeout or data corrupted in the transmission.

If this happens over localhost-connections (server and client in same computer), it could be a faulty memory, otherwise you might have a broken nic, router or cable somewhere along the line. If you're using wireless, they can be pretty unreliable.

This error occurs exactly due to problem in network. It comes when connection with your database failed and and application is unable to retrieve the required data. The problem may be in your connection wire or with the modem. Try changing them. Otherwise check your database access in sql developer etc if its working fine, there could be a problem in transaction timeout.

There are two possibilities:

  • The database is down, or
  • The database server's IP address duplicates an existing server's IP address on the network

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM