Thursday, April 6, 2023

Re: Question about setting GWT RPC timeout

I believe you're experiencing different timeouts in different cases. That is, the problem you're facing of a short timeout before you use your RPC_TIMEOUT_MS is a server-side timeout (or potentially a proxy?), but after you set a client-side timeout, the client is observing that the server is taking too long, and terminating the call from its side, resulting in the RequestTimeoutException.

To confirm this, try setting the client-side timeout to something like one minute, 60_000, and see that the error returns to the old message you were seeing. A timeout set like this does not guarantee that the server stops processing the request, only that the client stops waiting for it, and it may not be appropriate for your use case at all.

With the client-side timeout set to a reasonable amount or entirely removed, take a closer look at the error message you're getting from the server, and any server or proxy logs you're getting. If there is a proxy, see if you can connect directly to the server to rule out the proxy setting this short timeout. Very likely this is a configuration on the server/proxy that can be change to suit your requirements.

On Thursday, April 6, 2023 at 2:26:31 AM UTC-5 Dmitri wrote:
Dear gurus,

I'm learning Java and GWT and I'm facing a problem with setting timeout for PRC calls. I want to extend the RPC timeout before the client reports a failure. The code I'm using is attached below.

I'm running a client in firefox and experience the following problem:

I want to achieve a timeout of 20-30 seconds. However I can set the timeout (RPC_TIMEOUT_MS) only up to 3200mS. In case the server does not respond I receive the exception "com.google.gwt.http.client.RequestTimeoutException: A request timeout has expired after 3200 ms" accurately after defined time.

However in case set timeout exceeds the 3300ms of above the exception is different "com.google.gwt.user.client.rpc.StatusCodeException: 0" and is thrown always after 3-4 seconds.

What causes this exception and how can I extend the waiting time?

Thank you,
Best regards
Dmitri

The code:
public class MyClass implements EntryPoint {

  private static final int RPC_TIMEOUT_MS = 3300;

  private static class TimeoutRequestBuilder extends RpcRequestBuilder {
    @Override
    protected RequestBuilder doCreate(String serviceEntryPoint) {
  RequestBuilder builder = super.doCreate(serviceEntryPoint);
      builder.setTimeoutMillis(RPC_TIMEOUT_MS);
      return builder;
    }
  }

  private static final RpcRequestBuilder requestBuilder = new TimeoutRequestBuilder();
  private final HubServiceAsync myService = GWT.create(HubService.class);

  @Override
  public void onModuleLoad() {
    ((ServiceDefTarget) hmyService).setRpcRequestBuilder(requestBuilder);

    final MainView mainView = new MainView(hubService);

    RootPanel rootPanel = RootPanel.get();
    rootPanel.add(mainView);

    Window.addResizeHandler(new ResizeHandler() {
      @Override
      public void onResize(ResizeEvent event) {
        mainView.resize();
      }
    });
  }
}


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/76443417-083f-4401-94f5-cd9fd392f80fn%40googlegroups.com.

No comments:

Post a Comment