title: JBoss 6 socket timeout waiting for @Asynchronous method result
body: <p>I have a stateless EJB-3.1 session bean containing an asynchronous method that does some expensive processing and returns a future to the client, thereby allowing it to display the processing result once it's ready:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Asynchronous
  @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
  public Future&lt;String&gt; importModules() {
     String result = doSomeHeavyStuff();
     return new AsyncResult&lt;String&gt;(result);
  }
  </code></pre>
  
  <p>This bean is running on a JBoss 6 instance and invoked remotely from a Swing client:</p>
  
  <pre class="lang-java prettyprint-override"><code>final Future&lt;String&gt; termination =
              Proxy.getProxy().getMenfpImportService().importModules();
  
  SwingWorker&lt;String, Object&gt; worker = new SwingWorker&lt;String, Object&gt;() {
  
      @Override
      protected String doInBackground() {
          /* ... */
          if (termination.isDone()) {
               return termination.get();
          }
          /* ... */
      }
  
      /* ... */
  }
  </code></pre>
  
  <p>While the processing usually finishes successfully, some computations take longer than 300 seconds to finish. </p>
  
  <p>For these computations, a JBoss socket timeout causes the client to receive an ExecutionException instead of the computation result when calling termination.get():</p>
  
  <pre><code>10:26:16,301     INFO Application:1150 - Execution exception during modules import: 
  java.util.concurrent.ExecutionException: org.jboss.remoting.InvocationFailureException: Socket timed out.  Waited 300000 milliseconds for response while calling on InvokerLocator [socket://degotte:3873/?timeout=300000]; nested exception is: 
  java.net.SocketTimeoutException: Read timed out
  at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
  at java.util.concurrent.FutureTask.get(FutureTask.java:83)
  at org.jboss.ejb3.async.spi.AsynchronousClientFuture.get(AsynchronousClientFuture.java:113)
  at org.jboss.ejb3.async.impl.util.concurrent.LocalJvmSerializableFutureWrapper.get(LocalJvmSerializableFutureWrapper.java:161)
  at lu.lippmann.forminitiale.client.gui.Application$2.doInBackground(Application.java:1137)
  at lu.lippmann.forminitiale.client.gui.Application$2.doInBackground(Application.java:1)
  at javax.swing.SwingWorker$1.call(SwingWorker.java:277)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  at javax.swing.SwingWorker.run(SwingWorker.java:316)
  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>Unfortunately, the @Asynchronous annotation doesn't provide any configuration options.</p>
  
  <p>My question is how I can increase the client server communication socket timeout, and if in any way possible only for the connection established during the invocation of the asynchronous method.</p>
  
  <p>Thanks,
  Thomas</p>