locked
ajax call the .ashx file - timeout and keeping session alive RRS feed

  • Question

  • User1448655074 posted

    Hi All

    I have the below ajax call that I'm calling every minute

    The idea behind this is to keep the client session alive which works fine

    My question is when this is running on the client when will an error be captured in the ajax call?  ( I tried to test this by removing the network cable on the client but it wasn't captured by error).  No network so it can't get to the .ashx file and the timeouts and is captured?

    The point behind this is I have some vpn clients connections and sometimes perhaps 1 or 2 have dropped their sessions ( I know this because I cannot see their connections when running a netstat from the webserver).  When this happens I need to refresh their screen over the vpn connection so get a new session going.

    This may or may not be possible I suspect I 3rd witness kind of application will need to be running to monitor these connections?  But perhaps the below might work

    thanks

    function heartbeat() {
    
                    $.ajax({
                        type: "GET",
                        url: "<%= ResolveUrl("SessionHeartbeat.ashx") %>",
                        data: null,
                        timeout: 10000, 
                        success: function (data) {                       
                            beatHeart(30);                                        
                        },
                        failure: function () {                        
                            heartfail(400);
                            screenRefresh();
                        },
                       
                    });
                }

    Friday, February 2, 2018 10:38 AM

Answers

  • User475983607 posted

    As far as I know, there is no failure function in jQuery AJAX.  At least there's no failure function in the docs.

    http://api.jquery.com/jquery.ajax/

    Maybe replace failure with error.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 2, 2018 1:03 PM

All replies