Could not open socket

541 views
Skip to first unread message

Valpo Creative

unread,
Mar 31, 2012, 1:28:04 PM3/31/12
to reCAPTCHA
I actually quit using recaptcha because I am not an alien therefore
like other millions of ignored users that complain about recaptcha I
am unable to read it.. Anyways, unfortunately other sites are still
using this awful UN-human plugin including a site that I have an
account with and am currently locked out of with the message "Could
not open socket"?? Any one know anything about this issue and how to
fix it??

PJH

unread,
Mar 31, 2012, 2:30:51 PM3/31/12
to reca...@googlegroups.com
On Sat, Mar 31, 2012 at 5:28 PM, Valpo Creative <valpoc...@gmail.com> wrote:
> including a site that I have an
> account with and am currently locked out of with the message "Could
> not open socket"?? Any one know anything about this issue and how to
> fix it??

You contact the people who run the site and get them to fix it.
There's nothing you can do, as a user of that site, to 'fix' it.

--
PJH

Mick

unread,
Oct 3, 2012, 5:38:38 PM10/3/12
to reca...@googlegroups.com, pauljh...@gmail.com
and if you dont know how to contact them?

Adrian Godong

unread,
Oct 3, 2012, 7:53:54 PM10/3/12
to reca...@googlegroups.com, pauljh...@gmail.com
Then probably the site doesn't want your visit.

This is outside our control, and only the site owner can fix it.
> --
> You received this message because you are subscribed to the Google Groups
> "reCAPTCHA" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/recaptcha/-/avK5S0JB3w8J.
>
> To post to this group, send email to reca...@googlegroups.com.
> To unsubscribe from this group, send email to
> recaptcha+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/recaptcha?hl=en.



--
Adrian Godong
adrian...@gmail.com

Stuart Norman

unread,
Dec 18, 2013, 4:39:37 AM12/18/13
to reca...@googlegroups.com, pauljh...@gmail.com
This is outside our control, and only the site owner can fix it. 

Yeah, coz the site owner can fix it too. The "Could not open socket" error isn't anything to with websites or code, it's to do with Google f**king up with their code and servers. Coz  web designers like myself, want to use reCaptcha, except we also get the bloody error. With no immediate fix.

Adrian Godong

unread,
Dec 18, 2013, 12:37:20 PM12/18/13
to reca...@googlegroups.com
So to clarify, do you have access to the production servers? If you
do, you may want to check the firewall configuration so that your
production servers can talk to Google servers. This is required to use
reCAPTCHA.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to recaptcha+...@googlegroups.com.
> To post to this group, send email to reca...@googlegroups.com.
> Visit this group at http://groups.google.com/group/recaptcha.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Adrian Godong
adrian...@gmail.com

Stuart Norman

unread,
Dec 18, 2013, 7:42:06 PM12/18/13
to reca...@googlegroups.com
Yeah, I don't have a dedicated server, therefore it doesn't have a firewall. I'm on a standard Windows web hosting package with 1and1.co.uk. Surely reCaptcha should work on just about any web hosting configuration? I mean, not everyone can have the best of the best web hosting package. And surely if certain things are required for reCaptcha to work, then the reCaptcha people/Google should state that on their reCaptcha homepage.

Adrian Godong

unread,
Dec 18, 2013, 8:14:23 PM12/18/13
to reca...@googlegroups.com
Try contacting the host to see if they open port 80 to Google on their
firewall. This is a super common port to open (you need it, for
example, to browse the Internet and get updates for your server). I
don't see any reason to block it.

Stuart Norman

unread,
Dec 18, 2013, 8:21:09 PM12/18/13
to reca...@googlegroups.com
That's just it you see. I've already asked them if it's blocked. And they said port 80 is always open. So I'm at a loss for why it won't work.

Adrian Godong

unread,
Dec 19, 2013, 2:30:48 AM12/19/13
to reca...@googlegroups.com
If that's the case, make sure you have the latest version and post
your code here. We may be able to help if it's related to the code.

Stuart Norman

unread,
Dec 19, 2013, 3:52:51 AM12/19/13
to reca...@googlegroups.com
Yep, I have the latest version. I'm using the php plugin. To get the error, you don't even need to enter the correct recaptcha, type anything in the box and the error appears. Here is a test page: www.eastfieldjoinery.com/contact1.php So this is the code for the form in "contact1.php" : 

NOTE: (the 3 parts in yellow are the important bits to look at.)

<form id="contactform" action="contactform1.php" method="post">
    <table width="615" height="516" border="0">
  <tr>
    <td width="112" height="86" valign="top"><b>Full Name: <span style="color:#F00;">*</span></b></td>
    <td width="227" valign="top"><span id="firstname1">
    <input name="fullname" type="text" id="name" size="20" maxlength="40"><label class="form-label" for="name">First Name</label><br><span class="textfieldRequiredMsg">Please enter your first name.</span></span>
    </td>
    <td width="262" valign="top"><span id="surname1">
    <input name="surname" type="text" id="surname" size="20" maxlength="40">
            <label class="form-label" for="surname">Last Name</label>
            <br><span class="textfieldRequiredMsg">Please enter your last name.</span></span>
    </td>
  </tr>
     <tr><td valign="top"><label for="email"><b>Email address:</b></label></td><td valign="top"><input type="email" id="email" name="email" size="25" /></td></tr>
      
  <tr>
    <td valign="top"><b>Phone Number:</b></td>
    <td valign="top"><input name="phone" id="phone" type="text">
      </td></tr>
  <tr>
    <td height="214" valign="top"><b>Enquiry: <span style="color:#F00;">*</span></b></td>
    <td valign="top"><span id="enquiry">
    <textarea rows="10" cols="30" name="comments" id="comments"></textarea><br><br><span class="textareaRequiredMsg">Please enter your enquiry.</span></span></td>
  </tr><tr><td>
<!--the reCaptcha code-->
  <?php
  require_once('recaptchalib.php');
  $publickey = "(Some public key)"; // you got this from the signup page
  Print recaptcha_get_html($publickey, $error);
  ?>
  </td></tr>
  <tr><td></td>
    <td><br><input type="submit" value="Submit"><input type="reset" value="Clear Form"></td>
  </tr></table></form>

The next bit is in "contactform.php" (the form process):

<?php
// the reCaptcha code
require_once('recaptchalib.php');
$privatekey = "(Some private key)";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER['REMOTE_ADDR'],
$_POST['recaptcha_challenge_field'],
$_POST['recaptcha_response_field']);
if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");
  } else {
    // Your code here to handle a successful verification
  
  
$mailto = '(some email)' ;
$subject = "Eastfield Joinery New Enquiry" ;
$thankyouurl = "#thank-you" ;
$from = "(some email)";
$errorurl = "#error";

$email_is_required = 0;
$phone_is_required = 0;
$name_is_required = 1;
$surname_is_required = 1;
$comments_is_required = 1;
$uself = 0;
$forcelf = 0;
$use_envsender = 0;
$use_sendmailfrom = 0;
$use_utf8 = 1;

define( 'MAX_LINE_LENGTH', 998 );
$headersep = $uself ? "\n" : "\r\n" ;
$content_nl = $forcelf ? "\n" : (defined('PHP_EOL') ? PHP_EOL : "\n") ;
$content_type = $use_utf8 ? 'Content-Type: text/html; charset="utf-8"' : 'Content-Type: text/html; charset="iso-8859-1"' ;
if ($use_sendmailfrom) {
ini_set( 'sendmail_from', $mailto );
}
if (strlen($smtp_server_win)) {
ini_set( 'SMTP', $smtp_server_win );
}
$envsender = "-f$mailto" ;
$fullname = isset($_POST['fullname']) ? $_POST['fullname'] : $_POST['name'] ;
$surname = isset($_POST['surname']) ? $_POST['surname'] : $_POST['surname'] ;
$email = $_POST['email'] ;
$phone = $_POST ['phone'];
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}

if (empty($email)) {
$email = $from ;
}

$fromemail = $use_webmaster_email_for_from ? $from : $email ;

if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =
"<table border='0' cellspacing='0' cellpadding='0' width='100%'><tbody>

<tr><td style='text-align:center; background-color:#292d34;'><br><br><img src='http://www.eastfieldjoinery.com/Images/Title.png' width='465' height='40' /><br><br><br></td></tr>

<tr><td align='center'><br> 

<table border='0' cellspacing='0' cellpadding='0' width='600'><tbody>
<tr></tr>
</tbody></table>

<table border='0' cellspacing='0' cellpadding='0' width='600' bgcolor='#eeeeee'><tbody>
<tr><td align='center' bgcolor='white'>
<table border='0' cellspacing='0' cellpadding='5' width='100%'><tbody>

<tr><td style='text-decoration:underline; padding:5px !important; border-left:1px #000 solid; border-top:1px #000 solid;' width='170' bgcolor='white'><b>Question</b></td>

<td style='text-decoration:underline; padding:5px !important; border-left:1px #000 solid; border-top:1px #000 solid; border-right:1px #000 solid;' bgcolor='white'><b>Answer</b></td></tr>

<tr><td style='padding:5px !important; border-left:1px #000 solid; border-top:1px #000 solid;' width='170' bgcolor='white'>Name:</td>

<td style='padding:5px !important; border-left:1px #000 solid; border-top:1px #000 solid; border-right:1px #000 solid;' bgcolor='white'>$fullname $surname</td></tr>

<tr><td style='padding:5px !important; border-left:1px #000 solid; border-top:1px #000 solid;' width='170' bgcolor='white'>Email:</td>

<td style='padding:5px !important; border-left:1px #000 solid; border-top:1px #000 solid; border-right:1px #000 solid;' bgcolor='white'>$email</td></tr>

<tr><td style='padding:5px !important; border-left:1px #000 solid; border-top:1px #000 solid;' width='170' bgcolor='white'>Phone Number:</td>

<td style='padding:5px !important; border-left:1px #000 solid; border-top:1px #000 solid; border-right:1px #000 solid;' bgcolor='white'>$phone</td></tr>

<tr><td style='padding:5px !important; border-left:1px #000 solid; border-top:1px #000 solid; border-bottom:1px #000 solid;' width='170' bgcolor='white'>Enquiry:</td>

<td style='padding:5px !important; border:1px #000 solid;' bgcolor='white'>$comments</td></tr>

</tbody></table>
</td></tr>
</tbody></table>
</td></tr>
</tbody></table>" . $content_nl ;

$headers =
"From: \"$fullname $surname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.8" .
$headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;
$headers .= "Bcc: (Some email)\r\n";
  
if ($use_envsender) {
mail($mailto, $subject, $messageproper, $headers, $envsender );
}
else {
mail($mailto, $subject, $messageproper, $headers );
}
header( "Location: $thankyouurl" );
exit ;
}
?>

So that's my current code. I have tried various positions of the reCaptcha code, I've also tried a different form process altogether, but I still get the "Could not open socket" error.
I have changed the "define("RECAPTCHA_VERIFY_SERVER", "www.google.com");" part to many different variations in the "recaptchalip.php" but none work. I've added this ". $host . 
":" . $port . ":" . $errno . ":" . $errstr);" on the end of the fsockopen code in the "recaptchalip.php" file to return more info about the error. But as you can see, all I get is "www.google.com:80::"

I really hope you can help coz this is really bugging me.

Adrian Godong

unread,
Dec 19, 2013, 5:15:59 PM12/19/13
to reca...@googlegroups.com
Great. Now let's try hitting a different server to check if this
problem is specific to Google or not.

Create a new PHP file that contains the following:
<?php
function http_get($host, $path, $port = 80) {

$http_request = "POST $path HTTP/1.0\r\n";
$http_request .= "Host: $host\r\n";
$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
$http_request .= "\r\n";

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

fwrite($fs, $http_request);

while ( !feof($fs) )
$response .= fgets($fs, 1160); // One TCP-IP packet
fclose($fs);
$response = explode("\r\n\r\n", $response, 2);

return $response;
}

print http_get("www.google.com", "/");
print http_get("www.yahoo.com", "/");
print http_get("www.microsoft.com", "/");

?>

This code should perform a GET request to google, yahoo, and microsoft
and print the first packet response. See if all three fail or some. I
haven't touched PHP for years, so there may be a code error there and
hopefully easy to fix.

Stuart Norman

unread,
Dec 19, 2013, 8:47:03 PM12/19/13
to reca...@googlegroups.com
Yeah, it won't let anything happen. Still that "Could not open socket" error. So that means it's something to do with the web hosting server then. I've asked them to enable the fsockopen() if it's disabled, I'm still awaiting a reply. Is there anything else that I can do?
Reply all
Reply to author
Forward
0 new messages