invalid json response after sitting 7 min

invalid json response after sitting 7 min

crcucbcrcucb Posts: 59Questions: 17Answers: 0

I noticed that after sitting for approximately 7 min, when I go to work in the page with datatable (the source are editor files in php which is against ms sql) I get an json response. I started to look at the server settings where it's hosted, and I see this value:

session.gc_maxlifetime = 1440
Any suggestions on what I should look at or contact the hosting provider to ask?

Answers

  • crcucbcrcucb Posts: 59Questions: 17Answers: 0

    I was wrong, it's a little over 5 min

  • rf1234rf1234 Posts: 3,155Questions: 92Answers: 433
    edited July 24

    If you're having trouble with it, use SO, for example.
    https://stackoverflow.com/questions/75622923/in-php-session-is-default-for-1440second-24-min-so-if-user-is-active-then-also

    Before I start a session I run this code for example. To make a couple of changes without having to edit the php.ini file on the server.

    if ( strpos($_SERVER['HTTP_HOST'], 'localhost') === false ) { 
        ini_set('session.cookie_httponly', 1);
        ini_set('session.use_only_cookies', 1);
        ini_set('session.cookie_secure', 1);
        ini_set('session.cookie_samesite', "Strict");
        ini_set('session.gc_maxlifetime', 3600);
    }
    header("X-Frame-Options: DENY");
    session_start();
    
  • allanallan Posts: 64,798Questions: 1Answers: 10,728 Site admin

    If you are needing to wait for seconds, never mind minutes I'd very much recommend you consider enabling server-side processing.

    How big is your data set that it times out over 5 minutes?

    Allan

  • crcucbcrcucb Posts: 59Questions: 17Answers: 0

    I apologize for the confusion. The data takes several seconds to load & I can work just fine. But if I leave it idle for approximately 5 minutes, when I go to do anything after the 5 minutes I get the invalid json. DevTools is opened but everything looks blank so I am assuming there is some sort of idle timeout that I would like to expand but I am not sure where to look.

    However, I would like to look at shifting the execution to server site. But paging did not work when I set server: to and I didn't see an easy solution. I am licensed for editor.

  • kthorngrenkthorngren Posts: 22,186Questions: 26Answers: 5,106

    When server side processing is enabled the server script needs to support the Server Side Processing Protocol. This blog discusses using the Editor supplied server side libraries for server side processing. Maybe you can use the PHP server side library. Otherwise you will need to build your own support for server side paging, searching and sorting.

    Sorry I'm not familiar with PHP to help with the timeout issues.

    Kevin

  • allanallan Posts: 64,798Questions: 1Answers: 10,728 Site admin

    Sorry, I totally misunderstood!

    What is the server sending back if it isn't valid JSON? I expect there will either be an error message or it will be empty?

    Allan

  • rf1234rf1234 Posts: 3,155Questions: 92Answers: 433
    edited July 24

    Have you tried my recommendation above? That should fix the problem. Please also check whether you set a faulty logout timeout at the client side with JS. That could be the other cause of this.

  • crcucbcrcucb Posts: 59Questions: 17Answers: 0

    @allan , no worries. I have devtools open when this happens and when I inspect, everything is empty / clear.

    @rf1234 , I did add the php code to the top of the page/php.

  • allanallan Posts: 64,798Questions: 1Answers: 10,728 Site admin

    If it is clear, then that is why you are getting a JSON error - an empty string is not a valid JSON object. The question then becomes why the server is responding with an empty string.

    Are there any error messages in the PHP error log for your server? Do you have an early exit if a session or login doesn't exist? You could add some debug code into there to confirm if that is the path that the code is taking.

    Allan

Sign In or Register to comment.