title: Getting java.io.IOException: stream active in a client server Java socket program
body: <p>Before I post this I looked at some past questions on this exceptions but couldn't find an exact answar. </p>
  
  <p>I have a client server app which is basically a socket program connects with TCP.
  I got this Exceptions from client side after it runs fine for some time. But still, the client is sending data to the server even though it throws Exceptions.( may be as Event objects are passed continuously). But the server works fine as it receives the data. The Exception I get from the client side while sending data is </p>
  
  <p><code>java.io.IOException: stream active</code> .. This occurs from the "LINE 01" as mentioned in the code below.</p>
  
  <p>Here is the client code I used.</p>
  
  <pre><code>        // And "Event" objects are passed continuously to this method one by one.              
  
           SocketChannel socketChannel = null;
  
          try {
  
          socketChannel = SocketChannel.open(new InetSocketAddress(host, port));
          oos = new ObjectOutputStream(socketChannel.socket().getOutputStream());
          oos.reset(); -----------&gt; LINE 01
          oos.writeObject(event); 
  
      } catch (IOException e) {
          throw new RuntimeException(e);
      }
  </code></pre>
  
  <p>Here is the server code</p>
  
  <pre><code>    ServerSocketChannel serverSocketChannel = null;
      try {
          serverSocketChannel = ServerSocketChannel.open();
          serverSocketChannel.socket().bind(new InetSocketAddress(port));
  
          SocketChannel socket = serverSocketChannel.accept();
          ObjectInputStream ois = new ObjectInputStream(socket.socket().getInputStream());
           do {
                    Object object = ois.readObject();
                    if(object instanceof Event) {
                        Event event = (Event)object ;
                        viewDetailsInUI(event);
                    }
  
             } while (true);
  </code></pre>
  
  <p>Here is the stack trace I got from the client side.</p>
  
  <pre><code>java.io.IOException: stream active
      at java.io.ObjectOutputStream.reset(ObjectOutputStream.java:478)
      at org.demo.siddhi.server.EventSenderClient.sendEventToSubscriber(EventSenderClient.java:42)
      at org.demo.siddhi.server.query.types.SimpleStockQuoteVWAPQueryProvider$3.callBack(SimpleStockQuoteVWAPQueryProvider.java:344)
      at org.siddhi.core.OutputStreamHandler.run(OutputStreamHandler.java:61)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>Can anyone please explain why is this ?</p>