简体   繁体   English

发布的端点的连接数是否有限? [Java 1.6.0_16]

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

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. 我已经使用import javax.xml.ws.Endpoint和使用Service.create和service.getPort连接到它的客户端创建了一个Web服务。 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" 但是-如果我启动了说到我的Web服务的1000个并发连接(客户端),那么我将得到以下“有时”

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) (我正在使用JDK提供的轻量级HTTP服务器)

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. 当您连接到端点时,内置的HTTPServer将接受连接并将其移交给处理程序。 If the incoming requests come too fast, the HTTPServer has to put these connections in a queue creating a backlog. 如果传入的请求来得太快,则HTTPServer必须将这些连接放入队列中以创建积压。 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. 这可能会延迟错误,但是如果发送请求的速度超过服务器可以消化的速度,则最终会得到错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM