Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Handling session timeout and VPN disconnect

    Hi Team,

    I am using :
    SmartClient Version: v11.1p_2017-07-24/PowerEdition Deployment (built 2017-07-24)

    In my smartGWT application, i have three scenarios:
    1. Session timeout occurs. In this case, whenever a request is fired i get an error "The server failed to return a formatted response at all."
    2. The host is unreachable at an IP level (eg VPN disconnect.) In this case i get an error "Transport error - HTTP code: 0 for URL:"
    3. A reload happens in the middle of a request being sent. Then i get an error "Transport error - HTTP code: 0 for URL:".

    I want to show appropriate error in each case. Like "session timeout" in 1, and "Unable to connect to server" in case of 2. No message in case of 3.
    If i use the LoginRequiredMarker like below, i get "Session Time Out" in all cases.
    RPCManager.setLoginRequiredMarker("loginRequiredMarker");

    RPCManager.setHandleErrorCallback(new HandleErrorCallback() {

    @Override
    public void handleError(DSResponse response, DSRequest request) {


    final Dialog dialog = new Dialog();
    dialog.setShowCloseButton(false);
    dialog.setMessage("Session Time Out");
    Button button = new Button("OK");
    dialog.setButtons(button);
    button.addClickHandler(new ClickHandler() {

    @Override
    public void onClick(ClickEvent event) {
    Window.Location.assign(Window.Location.getPath());
    dialog.hide();
    }
    });
    dialog.draw();
    }
    });

    How can i handle the cases differently. Please help

    #2
    Hi swatiagarwal,

    try this code very early in your onModuleLoad() for 2 and 3:
    Code:
                    RPCManager.setHandleTransportErrorCallback(new HandleTransportErrorCallback() {
                        @Override
                        public void handleTransportError(int transactionNum, int status, int httpResponseCode, String httpResponseText) {
                            RPCManager.cancelDefaultErrorHandling();
                            SC.warn(i18n.networkErrorTitle(), i18n.networkErrorMessage());
                        }
                    });
    For 1, see Relogin here.

    Best regards
    Blama

    Comment


      #3
      Hi Blama
      Thanks for your reply.

      I am using spring controller on server side and using RPCManager.setActionURL on client side to send server calls. Also, in some cases i am using GWT aync calls. I do not want to show the pop up to relogin. Instead i want to redirect the user to login page when session expires. I have used spring security and redirected to login page on session expired. But, currently, whenever the session expires, the application in not redirected to the login page.
      How can i handle this. What string is given as the parameter in setLoginRequiredMarker() and is it required in my case.
      Also, for case 2 and 3 above, is there a way to show different messages.
      Last edited by swatiagarwal; 15 Mar 2018, 01:08.

      Comment


        #4
        The code Blama showed you already shows how to catch transport errors and show whatever message you want.

        The Relogin overview already explains that you can redirect to a login page (it's literally the first bullet point of 3). We would recommend revisiting it and giving it a much closer read.

        Comment

        Working...
        X