0

EDIT - it's an IPv6 issue

I've narrowed it down to that. details are here: Google Recaptcha check timeout due to IPv6 issue - php on IIS Thank you.

Original Question:

Google Recaptcha v2 has stopped working on a pile of my websites over the past 2 days, even though we've not made any changes to the code.

I check if the recaptcha has been entered correctly via php:

$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']);
$response = json_decode($response, true);

if($response["success"] !== true){

    header('HTTP/1.1 403 Recaptcha Incorrect'); 
    exit("The recaptcha was entered incorrectly. Please try again.");

};

Over the past 2 days it's stopped working. When not working google's servers appear to not be responding at all to the request made in the above code. I've not seen it come back as fail. It's just doesn't respond.

My VPS cannot communicate with google's servers?

It appears as if my VPS has suddenly stopped being able to communicate with google recaptcha servers:

  • I have not made any changes to the code.
  • It's been working inconsistently
  • The recaptcha works fine when I test it locally
  • The recaptcha works fine when I put the website on a test domain on azure (my VPS is not on azure).

Any ideas where I should start to fix this?

All ideas greatly appreciated as I'm at a loss as where to even look to get it working.

thanks.

Phil Teare
  • 417
  • 1
  • 6
  • 14
  • try logging in to reCaptcha console for any messages – frunkad Mar 30 '18 at 09:19
  • Thanks. Tried that but all it says is: "We detected that your site is verifying reCAPTCHA passed solutions less than 50% of the time. This could indicate a problem with your integration with reCAPTCHA. Please see our developer site for more information." – Phil Teare Mar 30 '18 at 09:24
  • try using the recaptchalib instead of the `file_get_contents` function https://developers.google.com/recaptcha/old/docs/php – frunkad Mar 30 '18 at 09:26
  • recaptchalib seems to be something for v1, whereas I'm using v2. All the examples I can find out there for vs use `file_get_contents`. Can i just check - are you suggesting I try using `recaptchalib` with v2? – Phil Teare Mar 30 '18 at 10:08
  • I think it must be something server related - it's like my server cannot communicated with google recaptcha server. The site is hosted on a VPS and does not worked. However I've tried putting it on a test domain on azure and it works fine. It's as if google's recaptcha server is ignoring requests from my VPS?? – Phil Teare Mar 30 '18 at 11:29
  • Inconsistently working across the board now - both on VPS and test domain on azure – Phil Teare Mar 30 '18 at 12:08

1 Answers1

1

This is because they are moving away from v1 calls

Any calls to the v1 API will not work after March 31, 2018. Starting in November 2017, a percentage of reCAPTCHA v1 traffic will begin to show a notice informing users that the old API will soon be retired.

https://developers.google.com/recaptcha/docs/faq

Instead use the new v2, https://developers.google.com/recaptcha/old/docs/php

frunkad
  • 2,433
  • 1
  • 23
  • 35
  • Thanks for that. I'm already using v2. I've just tried making a new key as per the instructions but it's still not working. – Phil Teare Mar 30 '18 at 10:10