[jboss-user] [Remoting] - Re: Socket keep alive with client EJB and RMI over HTTP

ron.sigal@jboss.com do-not-reply at jboss.com
Mon Aug 4 20:54:28 EDT 2008


I've been doing some experimenting, and I've found that if I run a loop like this:


  | 
  |       for (int i = 0; i < 100; i++)
  |       {
  |          Client client = new Client("http://localhost:5555");
  |          client.connect();
  |          client.invoke("abc");
  |          client.disconnect();
  |          Thread.sleep(5000);
  |       }
  | 

a new socket is created for each invocation, but if I reduce the delay to 4000 ms, a single socket gets reused.  So it seems that Sun's java.net.HttpURLConnection implementation has some built in socket recycling mechanism, which, unfortunately, is inaccessible from the outside.  I've tried playing with a ping mechanism to try to keep a single socket alive, but it's not working.  Even if it did, there's no guarantee that it would work in another Java implementation.

One solution would be to change org.jboss.remoting.transport.http.HTTPClientInvoker to use something other than HttpURLConnection, something like Apache HttpClient.  However, the sun is setting on Remoting 2 and rising on Remoting 3, so the time has passed for significant development of Remoting 2.  Instead, we'll just make sure the problem does not arise in Remoting 3.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4168599#4168599

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4168599



More information about the jboss-user mailing list