ajaybairagi / 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 8 years ago

GoogleCodeExporter commented 8 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 8 years ago
Here is my patched version of the recaptchalib.php

Original comment by l...@fgiltd.co.uk on 28 Oct 2008 at 9:10

Attachments:

GoogleCodeExporter commented 8 years ago
Why can't fedora 9 handle fsockopen correctly, that seems extremely broken.

Original comment by ben.maurer on 28 Oct 2008 at 2:57

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
It does it on my CentOS 5.2 (32bit) testing server too, and I installed the LAMP
stack from source (as the yum versions are so old!). Seems to either be a 
redhat or
php bug, I have googled it but not seen any answers.

Original comment by l...@fgiltd.co.uk on 28 Oct 2008 at 4:53

GoogleCodeExporter commented 8 years ago
Thank you, this fix has been implemented into WP-reCAPTCHA and will be in the 
next
release.

Original comment by jorgepbl...@gmail.com on 7 Nov 2008 at 11:40

GoogleCodeExporter commented 8 years ago
This fix can be dangerous because it does a dns resolution on every page view. 

Original comment by ben.maurer on 8 Nov 2008 at 12:27

GoogleCodeExporter commented 8 years ago
Dangerous?

I suppose it would be more efficient to only run the "gethostbyaddr()" just 
before it
is used by fsockopen in the function, but for simplicity I just altered the 
Constant
as it is at the top of the file.

Original comment by l...@fgiltd.co.uk on 9 Nov 2008 at 8:52

GoogleCodeExporter commented 8 years ago
How about in recaptcha_check_answer, right before the call to 
_recaptcha_http_post,
which is the function that calls fsockopen. This way it would only be called 
when it
needs to check the answer right?

define("RECAPTCHA_VERIFY_SERVER", gethostbyname('api-verify.recaptcha.net'));

$response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/verify",

Original comment by jorgepbl...@gmail.com on 9 Nov 2008 at 9:42

GoogleCodeExporter commented 8 years ago
Er, in that case I should just make it:

$response = _recaptcha_http_post (gethostbyname('api-verify.recaptcha.net'), 
"/verify",

Does that seem fine?

Original comment by jorgepbl...@gmail.com on 9 Nov 2008 at 9:43

GoogleCodeExporter commented 8 years ago
I tested the suggested fix but it still doesn't work. My site is hosted on 
aplusnet
bussines hosting plan, but on my local machine everything works perfect. 

Original comment by ivannedo...@gmail.com on 29 Jan 2009 at 10:05

GoogleCodeExporter commented 8 years ago
This fix doesn't work for me either. Always getting "Could not open socket" 
error.

Original comment by oleg.ana...@gmail.com on 4 Feb 2009 at 12:20

GoogleCodeExporter commented 8 years ago
Hi All,

I'm getting the same error... I have tried the fix, but it doesn't work...

any siggestion???

thanks all

vit

Original comment by FiNa...@gmail.com on 23 Jun 2009 at 5:23

GoogleCodeExporter commented 8 years ago
it fixed the issue for me

Original comment by opsi...@gmail.com on 14 Jul 2009 at 6:08

GoogleCodeExporter commented 8 years ago
I have tried that repatched version and I still get the 'could not open socket' 
error.

Original comment by leewal...@gmail.com on 16 Jul 2009 at 6:19

GoogleCodeExporter commented 8 years ago
Using the mediawiki plugin, fix doesn't work for me either...

Original comment by krakout on 2 Sep 2009 at 8:32

GoogleCodeExporter commented 8 years ago
I'm wondering if the server was offline. I just tried this fix and it worked. 
Just
for kicks and grins, I changed the code back to the original and it still 
worked. I'm
looking at coincidence.

I also found other threads where people changed their keys, which seemed to 
work for
some of them. Probably a timing thing. If the server came back on while you were
making your change, you met with success.

Original comment by btaylor@TaylorImages.com on 29 Oct 2009 at 10:09

GoogleCodeExporter commented 8 years ago
I changed my lib to allow the user to continue if the script could not connect. 
A
more secure solution would probably be to provide an alternate validation scheme
perhaps by setting $recaptcha_response->is_valid = alternate and checking for 
that in
the page script.

Line 80 is now:
/*die ('Could not open socket - reCaptcha');*/ return 'socket error';

Line 184... I wrapped the solution and existing code in an if-else:
if ($response == 'socket error')
{
$recaptcha_response->is_valid = true;
}
else
{
    $answers = explode ("\n", $response [1]);
    $recaptcha_response = new ReCaptchaResponse();

    if (trim ($answers [0]) == 'true') {
        $recaptcha_response->is_valid = true;
    }
    else {
        $recaptcha_response->is_valid = false;
        $recaptcha_response->error = $answers [1];
    }
}

Original comment by btaylor@TaylorImages.com on 29 Oct 2009 at 10:52

GoogleCodeExporter commented 8 years ago
 fix didn't work for me too... Still getting the error

Original comment by Dima.No...@gmail.com on 25 Jun 2010 at 5:53

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The reCAPTCHA wasn't entered correctly. Go back and try it again.(reCAPTCHA 
said: incorrect-captcha-sol) 

Original comment by haisanth...@gmail.com on 30 Jul 2010 at 5:56

GoogleCodeExporter commented 8 years ago
Looks like nobody cud solve this damn problem...... i ve tried all the 
suggestions to the same result..... "Could not open socket"

Original comment by boog...@gmail.com on 3 Aug 2010 at 10:17

GoogleCodeExporter commented 8 years ago
Can anybody update how to check if fsockopen() is working or not??

Original comment by boog...@gmail.com on 3 Aug 2010 at 10:19

GoogleCodeExporter commented 8 years ago
Are you guys behind a proxy server?

Original comment by jorgepbl...@gmail.com on 6 Aug 2010 at 8:54

GoogleCodeExporter commented 8 years ago
Im having the same problem on an ubuntu 10.04 LAMP and reCaptcha PHP plugin 
install.
Ive tried a couple of fixes from above and the problem is still there. Using a 
dedicated server from a respectable web hosting company.

The weird thing is, sometimes the errors pops-up, sometimes it doesn't. If the 
error pops-up, and try again, there's a chance it'll work. I guess it's about 
50/50 each time the script is ran.

Original comment by jako...@gmail.com on 7 Aug 2010 at 11:43

GoogleCodeExporter commented 8 years ago
google, i'll clap your asses!, i've lost 2 hours of my life screwing this 
captcha, and it's same socket error...Shame on you!

Original comment by mihaylov...@yandex.ru on 13 Aug 2010 at 4:37

GoogleCodeExporter commented 8 years ago
Am on centos 5.5 and its private domain and I still have the issue with latest 
2.9.7. Could someone help..

Original comment by saina...@gmail.com on 15 Aug 2010 at 5:10

GoogleCodeExporter commented 8 years ago
Same problem here on Debian Lenny, up to date system, latest library.

Original comment by wilcobee...@gmail.com on 16 Aug 2010 at 8:54

GoogleCodeExporter commented 8 years ago
you guys are using the plugin downloaded from this website? It's outdated, you 
should be using the one from here: 
http://wordpress.org/extend/plugins/wp-recaptcha/

Original comment by jorgepbl...@gmail.com on 16 Aug 2010 at 9:03

GoogleCodeExporter commented 8 years ago
The source code of comment 28 looks like a spammer/obscure download. Google, 
where is the fix for the original version?

Original comment by wilcobee...@gmail.com on 20 Aug 2010 at 9:09

GoogleCodeExporter commented 8 years ago
I'm having the same issue.

Google or ReCaptcha people. Any clue?

Debian GNU/Linux 5.0 here.

I've tried all of the above solutions, but none gave the optimal result.

Thanks in advance!!

Original comment by estevema...@gmail.com on 22 Aug 2010 at 12:36

GoogleCodeExporter commented 8 years ago
Solved this problem by applying the patch, then linking /etc/resolv.conf to 
/etc/httpd/etc/resolv.conf (in fedora) and /etc/apache2/etc/resolv.conf (in 
ubuntu...), then restarting apache....

Original comment by lawrence...@gmail.com on 8 Sep 2010 at 5:02

GoogleCodeExporter commented 8 years ago
It seems i am screwed!

Original comment by mse...@gmail.com on 6 Oct 2010 at 10:54

GoogleCodeExporter commented 8 years ago
Although it's been working flawlessly for more than a year, this issue suddenly 
appeared... why ?

I really don't know how to solve this because I didn't modify anything in PHP 
config. I've also tried fix from #1 without success.

Lawrence, did you get the issue suddenly like I did too or it never worked 
before ?

Original comment by rom.se...@gmail.com on 19 Oct 2010 at 8:31

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I found a fix to recaptchalib.php v1.11

-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");

Try to look for the IP address yourself if this one don't work, I'm not sure if 
its the same at different locations(?).

Original comment by yoni050...@gmail.com on 11 Nov 2010 at 6:56

GoogleCodeExporter commented 8 years ago
Make sure it isn't the server which is blocking it, I tried all different kinds 
of solutions but couldn't get it to work, then simply uploaded it onto another 
host, and it worked perfectly. 
And use the latest version with
 define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
works like a charm

Good luck

Original comment by i.iacopetta@gmail.com on 12 Nov 2010 at 12:36

GoogleCodeExporter commented 8 years ago
I had the same issue. Strangely I solved it by closing the php code after 
recaptha section, then immediately reopening it!

Original comment by samphi...@gmail.com on 28 Nov 2010 at 12:23

GoogleCodeExporter commented 8 years ago
actually the problem is back now

Original comment by samphi...@gmail.com on 29 Nov 2010 at 6:26

GoogleCodeExporter commented 8 years ago
I used recaptcha last week for first time and was okay..
but now, get the same problem

Original comment by bro...@gmail.com on 22 Dec 2010 at 6:53

GoogleCodeExporter commented 8 years ago
"Could not open socket" does anyone has the answer for this issue?

Original comment by juanena...@gmail.com on 22 Dec 2010 at 7:16

GoogleCodeExporter commented 8 years ago
I use the server of name: 000webspace.com, this server shows me the message 
"Could not open socket. " I do not know. but maybe in the server configuration 
can be done, but on my computer "appserv" seems all well and good

Original comment by eduardol...@gmail.com on 27 Dec 2010 at 5:34

GoogleCodeExporter commented 8 years ago
I use the server of name: 000webspace.com, this server shows me the message 
"Could not open socket. " I do not know. but maybe in the server configuration 
can be done, but on my computer "appserv" seems all well and good

Original comment by eduardol...@gmail.com on 27 Dec 2010 at 5:35

GoogleCodeExporter commented 8 years ago
I think those of us on shared hosting may get this problem because the host 
server admin is not allowing us to open sockets. I am using Zymic. There 
servers don't allow you to use sockets - so ReCaptcha is not a suitable 
solution :(

Original comment by adriandh...@gmail.com on 1 Jan 2011 at 10:09

GoogleCodeExporter commented 8 years ago
Any fix for this? cause i STILL have this problem... :(

Original comment by orenj...@gmail.com on 4 Jan 2011 at 8:17

GoogleCodeExporter commented 8 years ago
For several months reCaptcha is running smoothly and since yesterday I get a 
sudden the message "Could not open socket." Does anyone have a solution?

Original comment by ipr.werb...@googlemail.com on 6 Jan 2011 at 2:13

GoogleCodeExporter commented 8 years ago
Me too.  It's been has been fine for the last few months and then today it 
started happening again. http://commentwars.org/register 

Original comment by christop...@gmail.com on 7 Jan 2011 at 7:12

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
It's not programming problem. 
You have to ask network admin.. 
They have to open port :80 

Original comment by behappy....@gmail.com on 10 Feb 2011 at 12:26

GoogleCodeExporter commented 8 years ago
I've seen this port 80 thing mentioned on other forums.  

I don't think so.  

In my Fedora Core 13 system, I went so far as to take the firewall completely 
down and I still get the "Could not open socket".

This problem cropped up on system that was essentially running several months 
untouched.

From what I can tell, the problem comes from the system not being able to 
resolve a host name (wouldn't it be cool if the error message said that?).  
That can happen for a lot of reasons...

Original comment by jrp...@gmail.com on 23 Mar 2011 at 3:36

GoogleCodeExporter commented 8 years ago
I'm using recaptcha-form.1.2.zip downloaded from 
http://wordpress.org/extend/plugins/recaptcha-form/ and i'm getting the same 
error. I try to use the fix, but doesn't works for me. It's not seem to be a 
resolution problem...

Any solutions or new notice this issue?

Original comment by gacca...@gmail.com on 16 May 2011 at 6:41