Page 1 of 1

recaptcha causes socket errors.

Posted: Mon Jan 13, 2014 1:10 pm
by zmenchho
Script URL: http://support.pckeyboard.com
Version of script: 2.5.2
Hosting company: self
URL of phpinfo.php: http://support.pckeyboard.com/7sholen8/phpinfo.php
URL of session_test.php: http://support.pckeyboard.com/7sholen8/session_test.php
What terms did you try when SEARCHING for a solution:

Write your message below:

When we have recaptcha enabled, users are unable to submit tickets via the web interface, they receive an error, "Could not open socket". I disable recaptcha and it works just fine.

Re: recaptcha causes socket errors.

Posted: Mon Jan 13, 2014 7:34 pm
by Klemen
This happens because your server has problems connecting to www.google.com to verify API key.

This means either fsockopen function isn't working on the server or there is a DNS issue when looking up www.google.com

You can try changing this code in "inc/recaptcha/recaptchalib.php" from

Code: Select all

define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
to

Code: Select all

define("RECAPTCHA_VERIFY_SERVER", "74.125.227.48");
and see if that helps.

If not you will need to either disable recaptcha or check with your host why PHP fsockopen function can't connect to www.google.com on port 80.

Re: recaptcha causes socket errors.

Posted: Tue Jan 14, 2014 1:28 pm
by zmenchho
Actually I found the issue. . . the server was trying to connect on IPV6 and i guess recaptcha is not working with IPv6.

I changed this line

Code: Select all

      $response = '';
        if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
                die ('Could not open socket');
to

Code: Select all

        $response = '';
        if( false == ( $fs = @fsockopen(gethostbyname($host), $port, $errno, $errstr, 10) ) ) {
                die ('Could not open socket');

Re: recaptcha causes socket errors.

Posted: Tue Jan 14, 2014 3:23 pm
by Klemen
You might want to try IP approach as well, so your server doesn't have to do a host by name lookup everytime a captcha is loaded.