问题
I'm using GWT (Java to JavaScript) as front-end, and RPC mechanism (AJAX) to make server requests (Servlets are the keys).
Everything going smooth as of now.
Now a test-case has been generated like
1)Make a request to server
2)In between disconnect the internet of client (user).
3)We are handling that InvocationException by showing some message.
@Override
public void onFailure(Throwable caught) {
NTMaskAlert.unMask();
if(caught instanceof InvocationException){
NTFailureMessage.showFailureException(caught,"Network disconnected");
}
onNTFailure(caught);
}
3)Now client reconnected, user making a request.
Here is the interesting point.
As soon as the internet reconnected, the browser started processing the previous request, I observed this in fire-bug. If I disconnect twice and reconnected twice, automatically request going twice and duplication of data happening.
回答1:
The reason for is simply that this behaviour is typically what users want.
That is, if they are temporarily off of the network, for example because the wireless router is down, then most of the time they expect that the browser, mail, etc, will attempt to reconnect when the network is back, they don't expect to have to go to every window and "refresh" to get it to start working again.
来源:https://stackoverflow.com/questions/18820812/browser-it-self-making-request-on-request-failure-when-internet-reconnected