Browser it self making request on request failure,when internet reconnected

岁酱吖の 提交于 2019-12-21 17:28:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!