RPC Services do have timeouts, its just that by default they are set
to 0, which effectively means no timeout.
Here's what you can do to set timeouts on your services -
a) Create a custom RpcRequestBuilder, and set the desired timeout
public class MyRpcRequestBuilder extends RpcRequestBuilder {
@Override
protected RequestBuilder doCreate(String serviceEntryPoint)
{
RequestBuilder builder = new RequestBuilder
(RequestBuilder.POST, serviceEntryPoint);
builder.setTimeoutMillis(RPC_TIMEOUT);
return builder;
}
}
b) Set the custom RpcRequestBuilder immediately after your GWT.create
(..) call
//Can be a global object -- you don't have to create a new one
everytime
RpcRequestBuilder theBuilder = new MyRpcRequestBuilder();
MyServiceAsync service = GWT.create(MyService.class);
((ServiceDefTarget) service).setRpcRequestBuilder(theBuilder);
c) Use the service object to invoke methods as you normally do. In
your AsyncCallbacks onFailure(Throwable t), you can check
if (t instanceof RequestTimeoutException) {
/// handle timeouts..
}
thats it.
On Sep 10, 11:00 am, And <[email protected]> wrote:
> Hi,
> I couldn't find a way to set a timeout in GWT RPC call. Am I missing
> something or this is done deliberately?
>
> This feature is essential if your client use the system in low quality
> network. Responses from the server might be lost sometimes and we
> don't want obviously to loose one of two active connections to the
> server.
>
> I see there is nice implementation of timeout (with abort on
> XmlHttpRequest) in RequestBuilder class, so any http request in GWT
> supports timeout. Why I cannot use timeout with RPC? It should be easy
> to implement because RPC uses RequestBuilder anyway (if I understand
> GWT code correctly).
>
> Did anybody cope with this issue?
>
> Any help would be appreciated.
>
> Many thanks,
> Andrzej Bednarz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---