How to override the read timeout in Restlet Framework

41 Views Asked by At

We're facing here a problem with long term request, which gets a read timeout (java.net.SocketTimeoutException: Read timed out) leading the an HTTP ERROR 1001: Communication Error (1001) - The connector failed to complete the communication with the server

Out server application is implemented as a class derived from org.restlet.Application and configured via org.restlet.ext.spring.SpringServerServlet in web.xml and Spring context.

We can see that there are 2 Client objects being created at the application start (first request) where an implicit read timeout is being set to 60 seconds in org.restlet.Component during the execution of the method startClients(). But it is impossible to override this timeout settings. Any idea how this timeout could be adapted?

web.xml:

<servlet>
    <servlet-name>RestletServlet</servlet-name>
    <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class>
    <init-param>
        <param-name>org.restlet.application</param-name>
        <param-value>proxyRestProvider</param-value>
    </init-param>
    <init-param>
        <param-name>org.restlet.clients</param-name>
        <param-value>HTTP HTTPS</param-value>
    </init-param>
</servlet>

Setting timeouts over the context does not work:

    getContext().getParameters().add("readTimeout", String.valueOf(this.proxyReadTimeoutMs));
    getContext().getParameters().add("socketTimeout", String.valueOf(this.proxyReadTimeoutMs));
    getContext().getParameters().add("socketConnectTimeoutMs", String.valueOf(this.proxyConnectTimeoutMs));

    getContext().getClientDispatcher().getContext().getParameters().add("readTimeout", String.valueOf(this.proxyReadTimeoutMs));
    getContext().getClientDispatcher().getContext().getParameters().add("socketTimeout", String.valueOf(this.proxyReadTimeoutMs));
    getContext().getClientDispatcher().getContext().getParameters().add("socketConnectTimeoutMs", String.valueOf(this.proxyConnectTimeoutMs));
0

There are 0 best solutions below