Clickqueros / recaptcha

Automatically exported from code.google.com/p/recaptcha
0 stars 0 forks source link

recaptchalib.php: Could not open socket (Fix included) #26

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

The expected action is for the fsockopen (line 80) to connect, and not
return false. It is currently returning false because it can't seem to
connect to domain names, only IP addresses, on my development server.
Obviously this is a problem I need to address as it does it for other
things I use fsockopen for. To be fair though the library should accomodate
for this, especially as I am not using an obscure setup, it's a typical one
if you follow any LAMP guide for Fedora 9 to be honest.

I see the error message: Could not open socket. It runs die to produce this
error message, so if for whatever reason the RECAPTCHA_VERIFY_SERVER dns
does not resolve, the end user doesn't have a clue what has gone wrong, all
the form data they have submitted is lost. It should fail gracefully, and
allow the form submission to continue without verifying the captcha input.

What version of the product are you using? On what operating system?

recaptchalib.php (v1.1.0) Currently the latest stable release.

Fedora 9 (32bit)
Apache 2.2.9/PHP 5.2.6 (installed using yum from official fedora repos)

Please provide any additional information below.

// To fix the problem, find line 40 in recpatchalib.php and replace:
define("RECAPTCHA_VERIFY_SERVER", "api-verify.recaptcha.net");

// With this:
define("RECAPTCHA_VERIFY_SERVER", gethostbyname('api-verify.recaptcha.net'));

Original issue reported on code.google.com by l...@fgiltd.co.uk on 28 Oct 2008 at 9:04

GoogleCodeExporter commented 9 years ago
No solution. Me in the first half of the day got error and in the second half 
works fine with the same code. Seems google it self can help us.

Original comment by asthaler...@gmail.com on 16 Jul 2011 at 9:07

GoogleCodeExporter commented 9 years ago
We implemented ASL Security with mod_security and seemed to cause the issue so 
we are looking to see if there is a resolution there.

Original comment by goo...@businessfinderscanada.com on 25 Jul 2011 at 5:58

GoogleCodeExporter commented 9 years ago
I'm facing this same issue.. :/ could not open socket... Even with the fix.

I think google has abandoned recaptcha...

Big 404 here:

http://recaptcha.net/plugins/php/

Original comment by hudsan...@gmail.com on 31 Jul 2011 at 5:11

GoogleCodeExporter commented 9 years ago
@all: your web hosting must support php fsock function to do this . .

# sorry if my english is bad , i'm from west-borneo (indonesia) . . :)

Original comment by mitnick....@gmail.com on 4 Aug 2011 at 3:03

GoogleCodeExporter commented 9 years ago
Eish same here

Original comment by mlmaph...@gmail.com on 15 Aug 2011 at 11:58

GoogleCodeExporter commented 9 years ago
Eish same here, Could not open socket

Original comment by mlmaph...@gmail.com on 15 Aug 2011 at 11:59

GoogleCodeExporter commented 9 years ago
If this works on your local machine and not on you host domain then ask your 
host admin to open the port:80.

Original comment by joshul....@gmail.com on 14 Oct 2011 at 1:51

GoogleCodeExporter commented 9 years ago
Comment 17 by btaylor@TaylorImages.com, Oct 29, 2009 

------

Slightly modifying B Taylor's solution did the trick for me, it's not perfect 
but it's good enough and won't trigger any warning:

$recaptcha_response = new ReCaptchaResponse();
if ($response == 'socket error') {
    $recaptcha_response->is_valid = true;
} else {
    $answers = explode ("\n", $response [1]);
if (trim ($answers [0]) == 'true') {
    $recaptcha_response->is_valid = true;
} else {
     $recaptcha_response->is_valid = false;
     $recaptcha_response->error = $answers [1];
}
}
return $recaptcha_response;

Original comment by riemer.m...@gmail.com on 20 Oct 2011 at 1:49

GoogleCodeExporter commented 9 years ago
Please, why am i getting this error:

Image Verification failed!. Go back and try again.
(reCAPTCHA said: )

josephbupe

Original comment by Joseph.B...@gmail.com on 17 Dec 2011 at 2:17

GoogleCodeExporter commented 9 years ago
no, this fix doesnt work, it doesnt verify the correct letters given and gives 
error to re-enter them corectly. :(

Original comment by Dr.Mudda...@gmail.com on 6 Mar 2012 at 10:38

GoogleCodeExporter commented 9 years ago
I found the fix...
plz update ur recaptchalib.php from here
it works now :)

Original comment by Dr.Mudda...@gmail.com on 6 Mar 2012 at 11:05

GoogleCodeExporter commented 9 years ago
No, it still does not work. I've tried both downloading the newest lib, and 
making the suggested changes to it, but without success. 

Original comment by BadExo...@gmail.com on 8 Mar 2012 at 8:31

GoogleCodeExporter commented 9 years ago
Actually, it does work from a different host. Must be some kind of network 
infrastructure problem @ the host.

Original comment by BadExo...@gmail.com on 8 Mar 2012 at 10:19

GoogleCodeExporter commented 9 years ago
Has any recent progress been made against this issue? I'm still experiencing 
this problem after updating my lib to v1.11 and updating my public and private 
keys for my domain.

Original comment by Methvin....@gmail.com on 29 Apr 2012 at 11:51

GoogleCodeExporter commented 9 years ago
aqui la solución... Here the solution.. ;-)
http://hellowahab.wordpress.com/2012/02/15/recaptcha-cannot-connect-to-host-prob
lem-behind-a-proxy/

Original comment by argi...@gmail.com on 8 May 2012 at 7:48

GoogleCodeExporter commented 9 years ago
replace---->  define("RECAPTCHA_VERIFY_SERVER", "www.google.com"); to this

define("RECAPTCHA_VERIFY_SERVER", "74.125.236.178");

worked on Linux fedora 17

Original comment by dilush...@gmail.com on 15 Jun 2012 at 12:42

GoogleCodeExporter commented 9 years ago
What happens when/if Google changes their IP. You will have to change the code 
on each site you've made this fix to?

Original comment by reece.br...@gmail.com on 20 Jun 2012 at 9:41

GoogleCodeExporter commented 9 years ago
yes you're correct.i'm thinking this not a PHP problem or RECAPTCHA lib 
problem.something with OS or DNS problem i'm don't know much about it. if 
Google not changes their IP this fix should not be a problem.you can replace 
the modified RECAPTCHA lib on each site.     

Original comment by dilush...@gmail.com on 23 Jun 2012 at 10:46

GoogleCodeExporter commented 9 years ago
I was facing the same issue today. but i had solved my problem after i contact 
to my network administrator.

It is possible that you do not have direct access to port 80 as a organisation 
in which you are working has set up a proxy using a firewall system. so please 
contact your administrator before saying anything to google as we all depends 
on it.. :)

port 80 is used in function "_recaptcha_http_post" in recapchalib.php and the 
error of socket occurs on line 80 "@fsockopen" function.

I am using recaptcha on my localhost and it works fine for me. hope contacting 
to your network administrator or removing any kind of proxy from your server 
work for you all.

Have a nice day...

Original comment by develope...@gmail.com on 20 Jul 2012 at 9:41

GoogleCodeExporter commented 9 years ago
I am using WHMCS software and upon implementing recaptcha (comes included - as 
an option) it displays, but when I submit the form, it shows the following: 
reCAPTCHA Error: Could not open socket

What's worse, the library is obfuscated with ionCube (probably something they 
did to it and don't want it to be messed with). I am running a godaddy economy 
reseller account that is running CENTOS 6.2 x86_64, PHP v5.3. Not sure why this 
is acting up.

Original comment by jmora...@gtama.com on 21 Aug 2012 at 3:39

GoogleCodeExporter commented 9 years ago
The comment 66 resolved for me. 

"
replace---->  define("RECAPTCHA_VERIFY_SERVER", "www.google.com"); to this

define("RECAPTCHA_VERIFY_SERVER", "74.125.236.178");
"

Original comment by buen...@gmail.com on 17 Nov 2012 at 7:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hello I Read all the post!! Is there an other URL for 
RECAPTCHA_VERIFY_SERVER??? Cuz I get the Same Error: Could not open socket. I 
try everything!!! Y check it my configuration php.ini and mi allow_url_fopen 
its on!! and I try with gethostbyname()and failing too...

define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
define("RECAPTCHA_VERIFY_SERVER", "74.125.236.178");

This is a fragment of my library!! please help me!!!

Original comment by AL10529...@unadmexico.mx on 21 Feb 2013 at 8:25

GoogleCodeExporter commented 9 years ago
I have the same problem than AL10529...

Original comment by isidro1...@gmail.com on 4 Mar 2013 at 3:56

GoogleCodeExporter commented 9 years ago
what is this

Original comment by afspraak...@gmail.com on 13 Mar 2013 at 1:28

GoogleCodeExporter commented 9 years ago
I had this problem, it turned out my dedicated ubuntu 12.10 box was not 
preforming dns lookups.

Anyone that has this issue within on ubuntu / or similar distro check this :

Terminal : ping -c 4 google.com

if it replys -> ping: unknown host google.com

it means your name servers and resolv.conf isnt correct and you need to 
reconfigure it.

Edit this file :

/etc/resolv.conf || /etc/resolvconf/resolv.conf.d/head

# Google's...
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.1 # For my own domains on the machine.

then once done reconfigure the resolvconf via :

sudo dpkg-reconfigure resolvconf

then reboot the server via your host manager || power || sudo reboot

Then once back on the terminal check again that pinging google works.

Also note some hosting providers probably wont allow you to preform lookups / 
create sockets.

Original comment by wezura...@gmail.com on 21 Mar 2013 at 12:59

GoogleCodeExporter commented 9 years ago
Changing the verify line in the recaptchalib.php file worked for me.

as suggested above:
define("RECAPTCHA_VERIFY_SERVER", "74.125.236.178");

Original comment by achd...@gmail.com on 18 Apr 2013 at 5:04

GoogleCodeExporter commented 9 years ago
i am having same issue "could not open socket", how to solve this :(

Original comment by muneerab...@gmail.com on 1 Aug 2013 at 9:20

GoogleCodeExporter commented 9 years ago
Comments 66 and 78, worked for me, thanks guys!

Original comment by Axl....@gmail.com on 5 Aug 2013 at 6:14

GoogleCodeExporter commented 9 years ago
Not working Properly. e.g. if captcha code is given "abc def" and we are 
entering " abc defgh", then it does not show any error and if we enter "abc de" 
then also same issue is there.

Original comment by jaybhati...@gmail.com on 16 Aug 2013 at 8:52

GoogleCodeExporter commented 9 years ago
doesnt work on me either. This is only i get "The reCAPTCHA wasn't entered 
correctly. Go back and try it again.(reCAPTCHA said: )" No error message or 
success message

Original comment by lemonsky...@gmail.com on 4 Sep 2013 at 8:43

GoogleCodeExporter commented 9 years ago
I use @pfsockopen  instead of @fsockopen in recaptchalib.php  and problem solved

Original comment by BDele...@gmail.com on 15 Sep 2013 at 2:03

GoogleCodeExporter commented 9 years ago
Comments 83, worked for me, thanks guys!

Original comment by mbric...@stcsolutions.com.ve on 22 Oct 2013 at 10:41

GoogleCodeExporter commented 9 years ago
i use all the solution here, but still i have error. "Could not open socket". 
help please :(

Original comment by rlascano...@gmail.com on 5 Dec 2013 at 2:40

GoogleCodeExporter commented 9 years ago
I too used all solutions and nothing worked. Now I am requesting hosting 
provider to open port 80. Hope that helps.

Original comment by karwal.b...@gmail.com on 9 Jan 2014 at 11:12

GoogleCodeExporter commented 9 years ago
comment #35 worked for me:

"-in this line:
define("RECAPTCHA_VERIFY_SERVER", "www.google.com");

-replace "www.google.com" with it's IP address.
define("RECAPTCHA_VERIFY_SERVER", "173.194.36.104");"

Thanks!

Original comment by zarok1...@gmail.com on 6 Feb 2014 at 5:22

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
for those getting the "Go back and try again" message ... find the latest 
recaptchalib.php here http://code.google.com/p/recaptcha/ and then make the ip 
address change as outlined above

Original comment by peter.sc...@gmail.com on 16 Jul 2014 at 5:51

GoogleCodeExporter commented 9 years ago
Funcionó correctamente en  Joomla 2.5.4 luego de las siguientes modificaciones:

1) En Código: /public_html/plugins/captcha/recaptcha/recaptcha.php
a) Línea 24+-: const RECAPTCHA_API_SERVER = "http://api.recaptcha.net";
REEMPLAZADA POR:
const RECAPTCHA_API_SERVER = "http://www.google.com/recaptcha/api";

Línea 25+-: const RECAPTCHA_API_SECURE_SERVER = 
"https://www.google.com/recaptcha/api";

Línea 26+-: const RECAPTCHA_VERIFY_SERVER = "api-verify.recaptcha.net";
REEMPLAZADA POR:
const RECAPTCHA_VERIFY_SERVER = "www.google.com";

b) Línea 118 +-: $response = 
$this->_recaptcha_http_post(self::RECAPTCHA_VERIFY_SERVER, "/verify",
REEMPLAZADA POR:                
$response = $this->_recaptcha_http_post(self::RECAPTCHA_VERIFY_SERVER, 
"/recaptcha/api/verify",

c) Línea 189 +-: if (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) == 
false )
REEMPLAZADA POR:
if (($fs = @pfsockopen(gethostbyname($host), $port, $errno, $errstr, 10)) == 
false )

2) Parámetro PHP.ini: allow_url_fopen=On

Thanks!

Original comment by ros...@internea.com.ar on 15 Aug 2014 at 12:00