reCAPTCHA在验证时超时

时间:2016-03-31 22:26:58

标签: recaptcha

没有做任何更改(但也没有在几个月内对此进行测试),我的reCAPTCHA代码在尝试验证用户响应时(在localhost和我们的DEV服务器上)都超时。 IP正在错误消息中旋转(216.58.218.228:443,172.217.1.4:443,其他)。我通常认为这是一个防火墙问题 - 我无法在错误消息中telnet到IP /端口组合 - 但我可以在浏览器中提取https://www.google.com/recaptcha/api/siteverify并快速得到错误响应。关于可能发生的事情的任何想法?

我通常使用的代码:

// Prepare input.
var input = new NameValueCollection
{
    { "response", captcha },
    { "secret", _settings.SecretKey }
};

// Make call.
byte[] response;
using (WebClient client = new WebClient())
{
    response = client.UploadValues(_settings.VerificationUrl, Http.Verbs.POST, input);
}

// Parse response.
var body = Encoding.UTF8.GetString(response);
var result = JsonConvert.DeserializeObject<VerificationResponse>(body);
return result.Success;

尝试通过GET验证(按照建议的here):

using (WebClient client = new WebClient())
{
    var response = client.DownloadString($"https://www.google.com/recaptcha/api/siteverify?secret={_settings.SecretKey}&response={captcha}");
}

示例完整错误消息:

  

连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应216.58.218.228:443

0 个答案:

没有答案
相关问题