views:

249

answers:

1

I've created a Web Service using import javax.xml.ws.Endpoint and a client that connects to it using Service.create and service.getPort. Now, everything works perfectly fine when only using a small amount of connections...

But - if I launch lets say 1000 concurrent connections (Clients) to my Web Services I get the following "sometimes"

com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
... then it works ...
... works again ...
com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.ConnectException: Connection refused: connect
... works ...
... works ...

(you get the idea)

But this is not consistent ... so I am wondering ... is there a limit? (I am using the lightweight HTTP server provided by the JDK)

+1  A: 

There is no hard limit but the number of connections is certainly limited. Depending on your hardware and OS, the limit can vary from hundreds of simultaneous connections to thousands.

When you connect to the endpoint, the built-in HTTPServer will accept connections and handed it over to handlers. If the incoming requests come too fast, the HTTPServer has to put these connections in a queue creating a backlog. The backlog is limited. When this limit is reached, the new connection is rejected and you see the error on client.

You can increase the backlog by doing something like this,

   server = HttpServer.create(address, 128);

This may delay the error but you will eventually get it if you send request faster than the server can digest it.

ZZ Coder