I have doubts that this is a good solution. (even thought it works in
your case). Since Hessian supports HTTP 1.1. it has good reason to
leave a connection open so that it can reuse it, if you do the next
call to the same webservice.
We found that Hessian can do quit a number of subsequent calls on the
same connection and I sure this improves the speed a lot.
May you can tell what your test looks like. Are you getting a service
proxy for each webservice call or are you reusing old proxy objects.
???
Because of this we went as far as building a little cache of service
proxy objects so that our application can reuse the embedded
connection.
regards
christian campo
On Tue, 07 Dec 2004 09:21:13 +0100, Steen Jansdal <steen@xxx.dk> wrote:
> Hi,
>
> While doing a performance test of hessian I discovered a leak.
>
> I wrote a very simple server and a simple client with the purpose
> of testing how long 100000 method invocations would take.
> After approx. 5000 invocations I suddenly got an exception:
>
> java.net.BindException: Address already in use: connect
> at java.net.PlainSocketImpl.socketConnect(Native Method)
> at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
> at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
> at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
> at java.net.Socket.connect(Socket.java:452)
> at java.net.Socket.connect(Socket.java:402)
> at sun.net.NetworkClient.doConnect(NetworkClient.java:139)
> at sun.net.www.http.HttpClient.openServer(HttpClient.java:402)
> at sun.net.www.http.HttpClient.openServer(HttpClient.java:618)
> at sun.net.www.http.HttpClient.<init>(HttpClient.java:306)
> at sun.net.www.http.HttpClient.<init>(HttpClient.java:267)
> at sun.net.www.http.HttpClient.New(HttpClient.java:339)
> at sun.net.www.http.HttpClient.New(HttpClient.java:320)
> at sun.net.www.http.HttpClient.New(HttpClient.java:315)
> at
> sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:521)
> at
> sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:498)
> at
> sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:569)
> at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:123)
> at $Proxy0.getUser(Unknown Source)
> at dk.jansdal.hessian.Client.main(Client.java:38)
>
> By digging into the code I found that the connection to the server
> wasn't closed after each invocation. Only the garbage collector closed
> these connections but my code was faster than the garbage collector were
> able to close them.
>
> By explicitly closing the connection after each invocation the
> problem went away.
>
> In HessianProxy.java:
>
> Exchange
> try {
> URLConnection conn = _factory.openConnection(_url);
> conn.setRequestProperty("Content-Type", "text/xml");
> with
> try {
> URLConnection conn = _factory.openConnection(_url);
> try {
> conn.setRequestProperty("Content-Type", "text/xml");
>
> and exchange
> return in.readReply(method.getReturnType());
> } catch (HessianProtocolException e) {
> e.printStackTrace();
>
> with
> return in.readReply(method.getReturnType());
> } finally {
> ((HttpURLConnection)conn).disconnect();
> }
> } catch (HessianProtocolException e) {
> e.printStackTrace();
>
> Best regards
> Steen
>
>
-- christian campo (gmail.com)Received on Tue 07 Dec 2004 01:41:45 -0800
This archive was generated by hypermail 2.1.8 : Thu Sep 28 2006 - 20:16:40 PDT