7

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??

user1021085
  • 729
  • 3
  • 10
  • 28
  • 1
    possible duplicate of [java.net.SocketException: Software caused connection abort: recv failed](http://stackoverflow.com/questions/135919/java-net-socketexception-software-caused-connection-abort-recv-failed) – dogbane Jan 27 '12 at 15:35
  • ... And `ins` is a BufferedReader for what stream, exactly? You should post much more information – Óscar López Jan 27 '12 at 15:36
  • Added more info to my question – user1021085 Jan 27 '12 at 22:01
  • 1
    possible duplicate of [Official reasons for "Software caused connection abort: socket write error"](http://stackoverflow.com/questions/2126607/official-reasons-for-software-caused-connection-abort-socket-write-error) – user207421 Sep 18 '12 at 06:09

3 Answers3

5

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.

esaj
  • 15,875
  • 5
  • 38
  • 52
  • Added more info to the question – user1021085 Jan 27 '12 at 21:52
  • 1
    You modified the code (it gets port # etc from a properties file) and opened up 2 vlcs and went into Tools -> preferences -> Show settings: all -> Interface -> main interfaces -> rc -> check "do not open dos.." and type in 127.0.0.1:PORT_YOU_SET_IN_vlc.java in the "tcp command input"? (chose a different port in server and client and change accordingly in the tcp-command-input windows) - If you did that and it worked to pause and play - did you pause and let it sit for a while? Try 30+ minutes and see if it gives you the error then. Do other stuff while you wait the x minutes. Try 1-3 times. – user1021085 Jan 28 '12 at 13:19
  • I'm not familiar with VLC's networking, I commented out the vlc-related calls in the code. Also note that I do not have Windows-computers at home, only Linux, so they might behave completely differently. However, I still think that your exception is related to the network link going down unexpectedly (which might also be caused by the VLC doing something wacky), but further than that, I really don't know... – esaj Jan 28 '12 at 13:40
  • http://wiki.videolan.org/VLC_command-line_help lists multiple different timeout-options for VLC-networking, my best guess is that VLC will terminate the connection with TCP timeout after being paused for long enough. Unfortunately I don't think I can help you any further with this. – esaj Jan 28 '12 at 13:57
  • The exception wasn't vlc-related, though. It was the BufferedReader.readLine() that threw it – user1021085 Jan 28 '12 at 15:18
  • You could try changing your code so that it sends something (a sort of ping/alive -message) over the connection every now and then (say, once per minute or two), if there's no other traffic. Something along the way (like Windows or a network device) may decide that the connection can be killed, because there hasn't been any activity for a while. – esaj Jan 28 '12 at 15:39
  • I added a thread that sends messages every minute, "keepalives". Seems to be working for now, although sometimes it would take a lot of time before it gave me the error, sometimes a minute or two. It differes a lot. – user1021085 Jan 28 '12 at 20:06
0

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.

Suhail Gupta
  • 22,386
  • 64
  • 200
  • 328
-3

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
Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
  • The question is about the color of apple. You are trying to answer with the shape of apple. – Shoaeb Mar 15 '21 at 18:52