• Resolved AweCodeBox

    (@awecodebox)


    Hello dear sir/madam

    I’m trying to set up Rate Limiting and test it. I set up anyone’s requests exceed & If a human’s page views exceed to 1 per minute then Block it. after that, I wrote a while loop to make 300 requests using wp_remote_get but seems it doesn’t block my IP because it returns 200 code status each time. do I do wrong? How can I test this feature?

    screenshot of settings: https://prnt.sc/sLqEm-spHxOF

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

    (@wfpeter)

    Hi @awecodebox, thanks for reaching out.

    Rate Limiting with requests from the site’s own server back to itself, or within a development environment won’t have the desired effect as private IPs aren’t rate limited. I would use?cURL or a browser from another machine.

    Thanks,
    Peter.

    Thread Starter AweCodeBox

    (@awecodebox)

    I wrote the following function to make 500 requests from another server to my website that location on a different server

    function sendMultipleRequests($url, $numRequests = 500) {
    $mh = curl_multi_init();
    $handles = [];
    for ($i = 0; $i < $numRequests; $i++) {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // You can set other CURL options as needed
    
        curl_multi_add_handle($mh, $ch);
        $handles[] = $ch;
    }
    
    $running = null;
    do {
        curl_multi_exec($mh, $running);
    } while ($running > 0);
    
    $responses = [];
    foreach ($handles as $ch) {
        $responses[] = curl_multi_getcontent($ch);
        curl_multi_remove_handle($mh, $ch);
    }
    
    curl_multi_close($mh);
    
    var_dump( $responses );
    }
    
    // Example usage
    $url = 'https://example.com/wp-json/contact-form-7/v1';
    $responses = sendMultipleRequests($url);

    But as you can see in the following screenshot

    https://prnt.sc/1ZP8R4XQzJEs

    https://prnt.sc/sLqEm-spHxOF

    Can you tell me where my mistake is in this test?

    Or might it doesn’t work. I’m confusing

    Thread Starter AweCodeBox

    (@awecodebox)

    I figure it out

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Rate Limiting’ is closed to new replies.