Snapshot Stops with a "Connection Timeout" error

When a user tries to create a local destination snapshot on his blog ID 18, the snapshot runs fine, but after some time, it gives "SITE TEMPORARILY UNAVAILABLE. Connection timed out - please try again." error.

I contacted my server guys and this is what they said:

"looks like the load balancers are timing out then. out load balancers will cut the connection if the browser does not send any data back. the job may still be running, but the connection to the browser is cut.

So the plugin would need to add some sort of keepalive to keep the connection open. As long as the browser sends some data, it could just be a command to show a blinking period on the screen the connection will stay open for up to 15 mins.

It's not an issue with the browser, its an issue with the code on the site not sending data back to the load balancer. the code on the site tells the browser what to do. So if the code does not tell the browser to send data for longer than 30 seconds then the connection is closed. Even if the script is still running on the server. So it's not an issue with the browser, but the code itself not having a keep alive.

If they do have a keep alive on their code then that is not the issue then. Then it may be something else. None of the PHP nodes your sites use are under heavy load, the DB server only has a handful of connections. None of the connections to your sites DB were stacking. so from what I can tell on the infrastructure, there is no issue I can see."

  • Lindeni Mahlalela
    • Recruit

    Hello Corey Hayes

    I hope you are doing great today. Thank you for contacting us about it and we really appreciate it. We really appreciate your input and suggestions regarding this.

    I have created the following snippet that can be tried out to add the keep alive header on all Ajax requests to the server.

    if ( ! class_exists('jQuery_Post_Keep_Alive') ) {
        class jQuery_Post_Keep_Alive{
            public function __construct(){
                add_action('admin_footer', array($this, 'keep_alive_script') );
                add_action('wp_footer', array($this, 'keep_alive_script') );
            public function keep_alive_script(){ ?>
                <script type="text/javascript">
                            beforeSend: function(xhr) {
                                xhr.setRequestHeader("X-Connection", {
                                        return "Keep-Alive";
                                xhr.setRequestHeader("X-Keep-Alive", {
                                       return "timeout=300, max=10000";
        global $jkeepalive;
        $jkeepalive = new jQuery_Post_Keep_Alive();

    You can use this code in your theme's php function or as an mu-plugin that will be automatically loaded on the website including all subsites if you are using multisite. If you prefer to use it as an mu-plugin, then create a new .php file and paste the code with the opening PHP tag as follows:

    //the above code

    Save the file and upload it to your website in the folder: 'wp-content/mu-plugins'

    Then try to see how it goes. Check the headers of any ajax request on your page and see if the 'Connection: Keep-Alive' header was set or not. I have tested it on my site and it seems to be added as it should. Please note that in the code above I have set the "X-Connection" and "X-Keep-Alive" headers because I got an error saying:

    Attempt to set a forbidden header was denied: Connection

    I am not sure about the reason for that. Please test it on your site and if it works I will proceed to ask the senior developer to add this in the core of the plugin.

    I hope this helps and we appreciate your help in this regard.

    Have a nice day.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.