2 Replies Latest reply on Feb 18, 2008 11:41 PM by EJP

    SocketException Software abort!!!!!

      PLEASE help me guys, i have been struggling with this problem for quite a while and have searched the whole internet.
      i have to write a multithreader client server program for a videostore. anyway my client sends a request to the server to search for (lets say The Matrix) if I search the first time i get my result to the client (I am working with a MSSQL db). my problem is. is that when i send the request (from my client) the second time my client exists and throws an error :
      Error (SEARCHDB) : java.net.SocketException: Software caused connection abort: recv failed
      Java Result: 1
      here is my client code well part of it. i am sending an array through the network (Object Serialization)
        private void searchDB(String movie, String genre) {  
              Pattern patMovie = Pattern.compile("[A-Z][a-z]+\\s?[A-z]+");
              Pattern patGenre = Pattern.compile("[A-Z][a-z]+");
               Matcher mov = patMovie.matcher(movie);
               Matcher gen = patGenre.matcher(genre);
                if (!mov.matches() || !gen.matches()) {
                  try {
                      throw new SpellException("Error: Check your input!");
                  } catch (SpellException ex) {
                } else {
                     out.println("SELECT * FROM Movies WHERE movie_name LIKE '%" + movie +"%'" );
                     String s = null; //17/02              
                     SObject x = null;              
                     MovieBean[] r = new MovieBean[10];
                   try { 
                       while ((s = in.readLine()) != null) {                      <<<<<---------ERROR HERE, second time though
                          if (s.equals("Object")) {
                              x = (SObject)ois.readObject(); 
                              r = x.getObject();
                        if (!r.equals(null)) {
                          for (int i = 0; i < r.length; i++) {
                              MovieBean bean;
                              bean = r;
      if (bean != null) {
      System.out.println(bean.getId() + "\t" + bean.getName());
      } catch (SocketException e) {
      System.err.println("Error (SEARCHDB) : " + e.toString());
      } catch (ClassNotFoundException e) {
      System.err.println("Error (SEARCHDB) : " + e.toString());
      } catch (IOException e) {
      System.err.println("Error (SEARCHDB) : " + e.toString());
      please please help me guys                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
        • 1. Re: SocketException Software abort!!!!!
          So you searched every page on the Internet, every FTP site, every server, every host? I doubt it. Impossible.

          Anyway, to answer your question, it appears that you are handling the socket object outside of the class code you posted. Likely, your multi-threaded application is re-using the same socket object for every thread using it.

          Doing so will generate different Session IDs on each connection, but because your intention is to seperate the thread connections as unique, the host system recognizes that the Session ID of the socket stream that one thread sent a request on, came back from that host/port with a different Session ID (due to one of the other threads also making an attempt with its own Session ID), and bcause networks are built to deliver data to the correct process (port), it drops the packet and aborts the connection via the Operating System.

          If that's too hard to understand, let me put it this way:

          On the client
          Thread 1: Session ID 1234
          Thread 2: Session ID 5678

          On the server (the database server holding MS SQL)
          Session ID 1234

          So, on the client machine, threads 1 and 2 make requests. Thread 1 goes first and so MS SQL sees that connection and makes Session ID 1234 the link. Since (assumably) your client re-uses the same socket object that thread 1 uses for thread 2, when thread 2 makes a request the SQL server sees it as 1234 not 5678 and thus sends it back to the client with Session ID 1234. The OS (network card) reads the packet, it sees the SID as 1234, but process identifier (for thread 2) being the delivery point, and it knows that SID for thread 2 is 5678, it believes this to be a sort of attack or well, at least a breakdown on the TCP/IP stack or link problems and crashes (aborts) the connection.

          Thread 1, if it makes a request after thread 2 gets the abort back from the server, it should fail with a socket exception as the OS should have destroyed the underlying socket process and the JVM should have been made aware, and then passed onto the thread as an exception.
          • 2. Re: SocketException Software abort!!!!!
            Likely, your multi-threaded application is re-using the same socket object for every thread using it.

            Doing so will generate different Session IDs on each connection
            But there is only one socket object, so there is only one connection; there is no such thing as a Session ID in TCP/IP; and the situation described in reply #1 doesn't produce the exception the OP is experiencing, or indeed any exception at all.

            So none of this makes any sense whatsoever. Please don't post half-baked guesswork here.

            In fact, 'Software caused connection abort' is generally caused by previous network failures writing to the peer. See http://forum.java.sun.com/thread.jspa?threadID=748677.