gpt4 book ai didi

java - com.sun.net.httpserver.HttpServer 最大连接数?

转载 作者:行者123 更新时间:2023-11-30 05:15:21 26 4
gpt4 key购买 nike

有时(很少)当我连接到 com.sun.net.httpserver.HttpServer 的运行实例时,我会收到“连接被拒绝”消息。

有人知道这是为什么吗?它可以处理的连接数是否有线程限制?我可以增加吗?谢谢。-r

最佳答案

来自the doc :

When binding to an address and port number, the application can also specify an integer backlog parameter. This represents the maximum number of incoming TCP connections which the system will queue internally. Connections are queued while they are waiting to be accepted by the HttpServer. When the limit is reached, further connections may be rejected (or possibly ignored) by the underlying TCP implementation. Setting the right backlog value is a compromise between efficient resource usage in the TCP layer (not setting it too high) and allowing adequate throughput of incoming requests (not setting it too low).

您可能会看到这个。

或者,您是否使用 setExecutor() 设置执行程序。默认执行器配置的线程可能比您需要的要少,并且配置了适当的 ThreadPoolExecutor可能有效。

关于java - com.sun.net.httpserver.HttpServer 最大连接数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1645553/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com