I use Restlet to implement a web service. The client (also uses Restlet) makes many consecutive calls to the server, but after a small number of calls have completed successfully, further calls hang on the server on which the message is displayed:
INFO: Stop accepting new connections and transactions. Consider increasing the maximum number of threads.
I tried:
getContext().getParameters().add("maxThreads", "200");
but it doesnβt help. In any case, it seems that the client should be able to make an unlimited number of calls, and increasing maxThreads simply increases the limit. It seems that I am not releasing any resource or disconnecting after each client call, but I do not know how to do this.
The following (small how I could do this) stand-alone program demonstrates the problem. It starts a simple server, and then the client calls it a bunch of times:
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import org.restlet.Application; import org.restlet.Component; import org.restlet.Request; import org.restlet.Response; import org.restlet.Restlet; import org.restlet.Server; import org.restlet.data.MediaType; import org.restlet.data.Method; import org.restlet.data.Protocol; import org.restlet.data.Status; import org.restlet.representation.InputRepresentation; import org.restlet.representation.Representation; import org.restlet.resource.ClientResource; import org.restlet.resource.Directory; public class SimpleServerPut extends Component implements Runnable { private static final int PORT = 8080; private static int readToByteArray(InputStream inputStream, byte[] buf) throws IOException { int length = 0; int b; while ((b = inputStream.read()) != -1) { buf[length++] = (byte)b; } return length; } @Override public void run() { getContext().getParameters().add("maxThreads", "200");
source share