restlet / restlet-framework-java

The first REST API framework for Java
https://restlet.talend.com
Other
654 stars 284 forks source link

TimeoutException when call a ClientResource in ServerResource in version 2.3.12 #1319

Open piscesvivian opened 6 years ago

piscesvivian commented 6 years ago

code:

in client

  public AbstractClientResource extends ClientResource{
        // parameters set
        AbstractClientResource(Config config, String uri) {
            super(new Context(), config.getBasePath() + uri);
            this.getContext().getParameters().set("idleTimeout", "600000");
        }
    }
  // client resource
   SomeClientResouce extends AbstractClientResource implements SomeResource{

   // Descriptor is an entity
   Response post(Descriptor descriptor){
    return post(descriptor, Response.class);
  }
}

clientresource set idleTimeout is effective when simple call SomeClientResouce and it will not throw a TimeoutException in default 60 seconds.

we need combine mulity client in a single one, so i write another server call

   CombineClientResource extends AbstractClientResource implements CombineResource{

 // CombineDescriptor is an entity include a list of Descriptor
   Response post(CombineDescriptor descriptor){
        return post(descriptor, Response.class);
  }
}

and in server

 CombineServerResource implements CombineResource{

    // CombineDescriptor is an entity include a list of Descriptor
     Response post(CombineDescriptor descriptor){
            Response response = new Response();
            for (Descriptor desc: descriptor.getDescList())
            {
                response = new SomeClientResouce().post(descriptor, Response.class);
                response .combine(response);
            }
            return response ;
    }
}

when call this CombineClientResource, is will throw a TimeoutException, exception detail:

how could i do to prevent idleTimeout.

in java debug model, i found HttpClientHelper does not contain any Paramaters, but i have set one.

i don't understand why.

2017-04-18 14:56:58 WARN [qtp1264436088-101] InternalRouter.Client (log:232) - The HTTP request timed out.
java.util.concurrent.TimeoutException
    at org.eclipse.jetty.client.util.InputStreamResponseListener.get(InputStreamResponseListener.java:226)
    at org.restlet.ext.jetty.internal.JettyClientCall.sendRequest(JettyClientCall.java:287)
    at org.restlet.engine.adapter.ClientAdapter.commit(ClientAdapter.java:105)
    at org.restlet.engine.adapter.HttpClientHelper.handle(HttpClientHelper.java:119)
    at org.restlet.Client.handle(Client.java:153)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:641)
    at org.restlet.engine.component.ComponentClientDispatcher.doHandle(ComponentClientDispatcher.java:129)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.engine.util.ChildClientDispatcher.parentHandle(ChildClientDispatcher.java:139)
    at org.restlet.engine.util.ChildClientDispatcher.doHandle(ChildClientDispatcher.java:112)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.engine.util.ChildClientDispatcher.parentHandle(ChildClientDispatcher.java:139)
    at org.restlet.engine.util.ChildClientDispatcher.doHandle(ChildClientDispatcher.java:112)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:1093)
    at org.restlet.resource.ClientResource.handleOutbound(ClientResource.java:1179)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:1008)
    at org.restlet.resource.ClientResource.post(ClientResource.java:1449)
    at com.xxx.resource.client.SqlClientResource.executeSql(SqlClientResource.java:21)
    at com.xxx.client.ClientBaseImpl.executeSql(ClientBaseImpl.java:166)
    at com.xxx.hdm.server.job.InitJob.executeSql(InitJob.java:94)
    at comxxx.server.job.InitJob.executeTask(InitJob.java:75)
    at com.xxx.server.job.InitJob.init(InitJob.java:54)
    at com.hikvision.bigdata.hdm.server.resource.server.InitServerResource.init(InitServerResource.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.restlet.resource.ServerResource.doHandle(ServerResource.java:508)
    at org.restlet.resource.ServerResource.post(ServerResource.java:1341)
    at org.restlet.resource.ServerResource.doHandle(ServerResource.java:606)
    at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:662)
    at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:348)
    at org.restlet.resource.ServerResource.handle(ServerResource.java:1020)
    at org.restlet.resource.Finder.handle(Finder.java:236)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:641)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
    at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:77)
    at org.restlet.Application.handle(Application.java:385)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:641)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:641)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
    at org.restlet.Component.handle(Component.java:408)
    at org.restlet.Server.handle(Server.java:507)
    at org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:63)
    at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:143)
    at org.restlet.ext.jetty.JettyServerHelper$WrappedServer.handle(JettyServerHelper.java:256)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Thread.java:748)
2017-04-18 14:56:58 INFO [qtp1264436088-101] InternalRouter.HdmApplication (log:228) - Exception or error caught in server resource
org.restlet.resource.ResourceException: Communication Error (1001) - The connector failed to complete the communication with the server
    at org.restlet.resource.ClientResource.doError(ClientResource.java:592)
    at org.restlet.resource.ClientResource.handleInbound(ClientResource.java:1156)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:1009)
    at org.restlet.resource.ClientResource.post(ClientResource.java:1449)
    at com.xxx.client.resource.client.SqlClientResource.executeSql(SqlClientResource.java:21)
    at com.xxx.client.ClientBaseImpl.executeSql(ClientBaseImpl.java:166)
    at com.xxx.server.job.InitJob.executeSql(InitJob.java:94)
    at com.xxx.server.job.InitJob.executeTask(InitJob.java:75)
    at com.xxx.server.job.InitJob.init(InitJob.java:54)
    at com.hikvision.bigdata.hdm.server.resource.server.InitServerResource.init(InitServerResource.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.restlet.resource.ServerResource.doHandle(ServerResource.java:508)
    at org.restlet.resource.ServerResource.post(ServerResource.java:1341)
    at org.restlet.resource.ServerResource.doHandle(ServerResource.java:606)
    at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:662)
    at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:348)
    at org.restlet.resource.ServerResource.handle(ServerResource.java:1020)
    at org.restlet.resource.Finder.handle(Finder.java:236)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:641)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
    at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:77)
    at org.restlet.Application.handle(Application.java:385)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:641)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:641)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202)
    at org.restlet.Component.handle(Component.java:408)
    at org.restlet.Server.handle(Server.java:507)
    at org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:63)
    at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:143)
    at org.restlet.ext.jetty.JettyServerHelper$WrappedServer.handle(JettyServerHelper.java:256)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
    at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.TimeoutException
    at org.eclipse.jetty.client.util.InputStreamResponseListener.get(InputStreamResponseListener.java:226)
    at org.restlet.ext.jetty.internal.JettyClientCall.sendRequest(JettyClientCall.java:287)
    at org.restlet.engine.adapter.ClientAdapter.commit(ClientAdapter.java:105)
    at org.restlet.engine.adapter.HttpClientHelper.handle(HttpClientHelper.java:119)
    at org.restlet.Client.handle(Client.java:153)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Router.doHandle(Router.java:422)
    at org.restlet.routing.Router.handle(Router.java:641)
    at org.restlet.engine.component.ComponentClientDispatcher.doHandle(ComponentClientDispatcher.java:129)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.engine.util.ChildClientDispatcher.parentHandle(ChildClientDispatcher.java:139)
    at org.restlet.engine.util.ChildClientDispatcher.doHandle(ChildClientDispatcher.java:112)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.engine.util.ChildClientDispatcher.parentHandle(ChildClientDispatcher.java:139)
    at org.restlet.engine.util.ChildClientDispatcher.doHandle(ChildClientDispatcher.java:112)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.routing.Filter.doHandle(Filter.java:150)
    at org.restlet.routing.Filter.handle(Filter.java:197)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:1093)
    at org.restlet.resource.ClientResource.handleOutbound(ClientResource.java:1179)
    at org.restlet.resource.ClientResource.handle(ClientResource.java:1008)
thboileau commented 6 years ago

hello @piscesvivian

I feel sorry for the late, late answer. Thanks you for the details, it helps a lot.