• Resolved masadri

    (@masadri)


    I’m using TML with reCAPTCHA on a http site whitout any problem and it works fine. But when i try to activate it on a https one it always give me this error: “Error connecting to the reCAPTCHA API host.” from register page. The first one location is on host, and the 2nd one is on a VPS and I’ve also checked its firewall, it doesn’t block any incomming or outgoing connection from port 80(http) and 443(https).
    Would please help me to find out what causes this problem?

    Thx.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter masadri

    (@masadri)

    I’m sorry for my mistake its error is: “Unable to reach the reCAPTCHA server.”

    I’ve looked at the recaptcha.php and found out that error code is “recaptcha-not-reachable”

    • This reply was modified 9 years, 1 month ago by masadri.
    Thread Starter masadri

    (@masadri)

    I’ve found out its problem after 3 or 4 days by reviewing recaptcha module from its plugin folder. Its error caused by wp_remote_post timeout so I added a filter for increasing its timeout and it is working great.

    hope help anyone who encounter this problem.

    here is filter:

    add_filter( 'http_request_timeout', 'wp_post_timeout_extend' );
    
    function wp_post_timeout_extend( $time )
    {
        // Default timeout is 5
        return 600;
    }

    or you can add timeout arg to wp_remote_post in [theme-my-login-folder]/modules/recaptcha/recaptcha.php :

    ....
    ....
    ....
    public function recaptcha_validate( $response, $remote_ip = '' ) {
    
    		if ( empty( $remote_ip ) )
    			$remote_ip = $_SERVER['REMOTE_ADDR'];
    
    		$response = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', array(
    /*****THIS PART*****/	'timeout' => 600,		
    			'body' => array(
    				'secret'   => $this->get_option( 'private_key' ),
    				'response' => $response,
    				'remoteip' => $remote_ip
    			)
    		) );
    ....
    ....
    ....
    • This reply was modified 9 years, 1 month ago by masadri.
    • This reply was modified 9 years, 1 month ago by masadri.
    • This reply was modified 9 years, 1 month ago by masadri.

    Thanks a lot! You saved me!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Error connecting to the reCAPTCHA API host’ is closed to new replies.