title: java.io.IOException: An established connection was aborted by the software in your host machine
body: <p>I am using the wAsync library, Websocket protocol and Atmosphere to send request, by following this article:
  <a href="https://github.com/Atmosphere/wasync/wiki/Getting-Started-with-wAsync" rel="nofollow">https://github.com/Atmosphere/wasync/wiki/Getting-Started-with-wAsync</a></p>
  
  <p>Here is what I have implemented:</p>
  
  <pre><code>    try
      {
          AtmosphereClient client = ClientFactory.getDefault().newClient(AtmosphereClient.class);
          RequestBuilder&lt;?&gt; requestBuilder =
              client.newRequestBuilder()
                  .method(Request.METHOD.GET)
                  .uri(url)
                  .trackMessageLength(false)
                  .transport(Request.TRANSPORT.WEBSOCKET)        // Try Websocket.
                  .transport(Request.TRANSPORT.LONG_POLLING);    // Fall back to Long pooling.
  
          final Socket socket = client.create();
          socket.open(requestBuilder.build()).fire(pMessage);
          socket.close();
      }
      catch (Exception e)
      {
      }
  </code></pre>
  
  <p>The <code>socket.fire</code> works successfully. </p>
  
  <p>But sometimes I receive the following error:</p>
  
  <pre><code>15:11:36,467 ERROR [org.atmosphere.container.JSR356Endpoint] (http-localhost/127.0.0.1:8080-79) : java.io.IOException: An established connection was aborted by the software in your host machine
      at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.write0(Native Method) [rt.jar:1.7.0_76]
      at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.access$900(WindowsAsynchronousSocketChannelImpl.java:43) [rt.jar:1.7.0_76]
      at sun.nio.ch.WindowsAsynchronousSocketChannelImpl$WriteTask.run(WindowsAsynchronousSocketChannelImpl.java:777) [rt.jar:1.7.0_76]
      at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.implWrite(WindowsAsynchronousSocketChannelImpl.java:914) [rt.jar:1.7.0_76]
      at sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:381) [rt.jar:1.7.0_76]
      at sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:398) [rt.jar:1.7.0_76]
      at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:978) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
      at org.apache.coyote.http11.InternalNioOutputBuffer$1.completed(InternalNioOutputBuffer.java:231) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
      at org.apache.coyote.http11.InternalNioOutputBuffer$1.completed(InternalNioOutputBuffer.java:200) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
      at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) [rt.jar:1.7.0_76]
      at sun.nio.ch.Invoker$2.run(Invoker.java:218) [rt.jar:1.7.0_76]
      at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) [rt.jar:1.7.0_76]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_76]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_76]
      at org.apache.tomcat.util.net.NioEndpoint$DefaultThreadFactory$1$1.run(NioEndpoint.java:1249) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
      at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_76]
  
  15:11:36,469 ERROR [org.atmosphere.container.JSR356Endpoint] (http-localhost/127.0.0.1:8080-79) : java.io.IOException: An established connection was aborted by the software in your host machine
      at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.write0(Native Method) [rt.jar:1.7.0_76]
      at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.access$900(WindowsAsynchronousSocketChannelImpl.java:43) [rt.jar:1.7.0_76]
      at sun.nio.ch.WindowsAsynchronousSocketChannelImpl$WriteTask.run(WindowsAsynchronousSocketChannelImpl.java:777) [rt.jar:1.7.0_76]
      at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.implWrite(WindowsAsynchronousSocketChannelImpl.java:914) [rt.jar:1.7.0_76]
      at sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:381) [rt.jar:1.7.0_76]
      at sun.nio.ch.AsynchronousSocketChannelImpl.write(AsynchronousSocketChannelImpl.java:398) [rt.jar:1.7.0_76]
      at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:978) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
      at org.apache.coyote.http11.InternalNioOutputBuffer$1.completed(InternalNioOutputBuffer.java:231) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
      at org.apache.coyote.http11.InternalNioOutputBuffer$1.completed(InternalNioOutputBuffer.java:200) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
      at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) [rt.jar:1.7.0_76]
      at sun.nio.ch.Invoker$2.run(Invoker.java:218) [rt.jar:1.7.0_76]
      at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) [rt.jar:1.7.0_76]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_76]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_76]
      at org.apache.tomcat.util.net.NioEndpoint$DefaultThreadFactory$1$1.run(NioEndpoint.java:1249) [jbossweb-7.5.7.Final-redhat-1.jar:7.5.7.Final-redhat-1]
      at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_76]
  </code></pre>
  
  <p>This error can't be caught by try-catch block.</p>
  
  <p>If I remove <code>socket.close()</code>, this error never occurs.</p>
  
  <p>Anybody knows why? How should I solve this? Or is there a way to catch this exception?</p>
  
  <p>Thanks in advance!</p>
  
  <p>***************** <strong>UPDATE</strong> **********************</p>
  
  <p>The socket needs to be closed.</p>
  
  <p>Is there a callback method that I can invoke when the fire operation completes?</p>