HttpServer - what is maximum threads allowed to connect?

I'm using Java6 and the HttpServer that comes with it. But I've hit a maximum that I cannot find what the value is or how to set it higher. I'm getting connection refused once that max is hit.

HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);

server.createContext("/admin", new AdminHandler());

server.setExecutor(Executors.newCachedThreadPool());

server.start();

It must be in the newCachedThreadPool() used.I like that it will reuse idle threads, and close them once an idle period passes, so that the number of threads does not grow or need to be fixed. But... I'm unclear as to how many incomming connections this will allow. Or how to change that default?

Or, should I be using another kind of Executor?

Thanks for any help.

-G

[812 byte] By [gjb9876a] at [2007-11-27 0:46:24]
# 1
It doesn't place any limit AFAIK. The limit you hit will probably be the JVM or OS limits on threads or sockets or file descriptors or maybe even just memory.
ejpa at 2007-7-11 23:12:30 > top of Java-index,Core,Core APIs...
# 2

perhaps there is some jvm limit or something... but I used the same code in a servlet under tomcat and our stresstests all passed then. I simply removed tomcat and the servlet and wrapped my code inside the HttpServer to see how it would handle. and my stress tests now fail.

any further ideas? we'd like to ditch tomcat because this is just a quick little webserver to perform some business logic.

Thanks :)

gjb9876a at 2007-7-11 23:12:30 > top of Java-index,Core,Core APIs...
# 3
I would try setting a higher backlog, say 500.
ejpa at 2007-7-11 23:12:30 > top of Java-index,Core,Core APIs...
# 4
> and the HttpServer that comes with itWhere we could find it?
hiwaa at 2007-7-11 23:12:30 > top of Java-index,Core,Core APIs...
# 5
Java 1.6 http://java.sun.com/javase/6/docs/technotes/guides/net/index.html http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/package-summary.html
ejpa at 2007-7-11 23:12:30 > top of Java-index,Core,Core APIs...