• Resolved Michael Ott

    (@mikeyott)


    I’ve been trying to find the source of an ongoing recent problem, where the website resource limit would be reached (and cause the site to fall over).

    I’ve narrowed it down to the fact that everyone who is using my plugin, the plugin is consistently hitting my website with non-stop license check requests. I am getting over a hundred thousand requests before lunch. Every domain running my plugin sends thousands of these requests daily.

    This is the exact same issue someone else described here: https://www.ads-software.com/support/topic/license-checker-wp_remote_get/ using this…

    $response = wp_remote_get($query, array(‘timeout’ => 20, ‘sslverify’ => false));

    …to verify the license key hasn’t expired. But unfortunately he did not share his solution.

    Can you suggest a way to only run the license check once per day? I tried putting it inside a cron job but that did not work.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support mbrsolution

    (@mbrsolution)

    Hi, I was just wondering if you have found a solution to your problem?

    Thank you

    Thread Starter Michael Ott

    (@mikeyott)

    @mbrsolution

    Yes I did, and although it’s not pretty it does indeed solve the problem.

    function the_update_checker() {
    // Your update checker function goes here.
    }
    
    // Admin pages allowed to make the license check API call.
    $allowed_pages = array(
        '/wp-admin/update-core.php', 
        '/wp-admin/plugins.php', 
        '/wp-admin/plugin-install.php', 
        '/wp-admin/admin-ajax.php', 
        '/wp-admin/update.php', 
    );
    // If on any of the allowed pages, run the update checker function.
    if (in_array($_SERVER['SCRIPT_NAME'], $allowed_pages)) {
        the_update_checker();
    } 

    This basically only allows the update checker API call to work when on any of the admin pages that typically check for updates, such as the Plugins page, the Updates pages. I’ve also included a few that are required for the ‘View version x.x.x details’ link on the plugin page next to your plugin to work, otherwise you’d get a ‘Plugin not found’ error.

    Also if care about supporting multi-site, you should duplicate all the items in $allowed_pages but with /wp-admin/network/, so like /wp-admin/network/update-core.php etc.

    I know this is not perfect, and the only way an administrator would know there is an update would be when they are on the Plugins or Updates pages. But it’s worth the sacrifice IMHO.

    Since doing this I’ve seen my resource limit come down drastically with each passing day as more users update the plugin.

    If you come up with a better solution, I’m all ears.

    • This reply was modified 3 years, 12 months ago by Michael Ott.
    Plugin Support mbrsolution

    (@mbrsolution)

    Thank you for sharing ??

    This will help others running into the same issue as you.

    Kind regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Too many activated licenses causes website use all resources’ is closed to new replies.