开发者

Does a published endpoint have a limited number of connections? [Java 1.6.0_16]

开发者 https://www.devze.com 2022-12-12 02:53 出处:网络
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.

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.ClientTransportExce开发者_如何转开发ption: 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)


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消