Hi all,

I came across this thread, I have searched if there is some "global" 
request timeout that we can set on a RPC calls, not RequestBuilder, but the 
one from RemoteService created via GWT.create(service) ? 
I coudnt find anything, any idea?

Tnx

On Thursday, April 6, 2023 at 2:16:47 PM UTC+2 Colin Alworth wrote:

> What you're looking for is a way to re-try requests in the case where the 
> server is unreachable, which is not something that HTTP or the browser 
> gives you automatically. If you had a proxy, but the server itself was 
> down, the proxy would likely return a 503 service unavailable status, which 
> the client could use to retry until the service was available (which might 
> only happen for a certain number of seconds or a certain number of tries). 
> It might also be possible for a proxy to wait and retry the upstream server 
> until it was available, but I can't think of a proxy right now with that 
> feature.
>
> HTTP itself doesn't have a timeout feature at all either. The timeout that 
> you're setting on the client side is a simple GWT Timer, if the request 
> hasn't finished (either in success or failure), it cancels the upstream 
> request and presents the failure you're seeing to the client.
>
> Be a little careful when implementing a retry mechanism, as it is possible 
> that the call made it to the server, and the server performed the action, 
> but the client lost internet connection while the response was on its way 
> to the client - that is, retrying a non-idempotent or expensive action may 
> cause problems you weren't expecting. A status code of 0 is usually the 
> client's way of saying "I wasn't able to get any reply from the server for 
> some reason" - taking that information and trying to do something simple 
> and idempotent until a server connection can be reestablished lets you know 
> that the server and network are both working again, followed by some "did 
> my last action succeed" before trying again (or just let the user dismiss 
> the message and try again) will help mitigate this class of issues. A proxy 
> sending back a 503 is a safer way to be sure that the network connection is 
> good, but only the server is down, so you can retry - but be aware that 
> technically there might be a network issue between the proxy and server, 
> though this is much less likely.
>
> Good luck,
> Colin
>
> On Thursday, April 6, 2023 at 7:05:53 AM UTC-5 Dmitri wrote:
>
>> Dear Colin
>>
>> Thank you so much for your advice. I'll take a closer look at those areas.
>>
>> Just a little clarification: The server is not running at all. Both 
>> exceptions are generated from the client only with different timeout 
>> settings when it cannot reach the server.
>> When the server is running - no problems in both cases. The purpose of 
>> the code is to make the client wait longer when the server is unreachable 
>> due to temporary communication problems.
>>
>> PS there are some typos in the codes I provide which I made when clean-up 
>> for posting., Please ignore them.
>> Thank you again
>>
>> Best regards
>> Dmitri
>>
>>
>> On Thu, Apr 6, 2023 at 9:49 PM Colin Alworth <nilo...@gmail.com> wrote:
>>
>>> 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-tool...@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
>>>  
>>> <https://groups.google.com/d/msgid/google-web-toolkit/76443417-083f-4401-94f5-cd9fd392f80fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit/0c5ac093-ca0d-42c0-ba4b-2aa1ca884f67n%40googlegroups.com.

Reply via email to