简体   繁体   English

Spring Boot Recaptcha配置

[英]Spring Boot Recaptcha Configuration

I'm developing an application on spring boot, however I needed to integrate recaptcha for security purposes on various forms, however the connection always results in a connection timed out, I verified api and the url with postman and it goes through and returns an answer, however on Java code times run out and I get the error java.net.ConnectException: Connection timed out: connect I don't know what I'm doing wrong I use the postman code that provides on "Java OK HTTP". 我正在开发一个基于Spring Boot的应用程序,但是出于安全目的,我需要以各种形式集成Recaptcha,但是连接始终会导致连接超时,我用邮递员验证了api和url,它通过并返回了答案,但是在Java代码上,时间用完了,并且出现错误java.net.ConnectException: Connection timed out: connect我不知道我做错了什么,我使用在“ Java OK HTTP”上提供的邮递员代码。 code is the next one. 代码是下一个。

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
.url("https://www.google.com/recaptcha/api/siteverify?secret=XX&response=XXX")
.get()
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "f47548e1-a9e0-9065-7f76-dced294bddcb")
.build();

Response response = client.newCall(request).execute();

However I don't seem to get where the error is, can someone help me? 但是我似乎无法理解错误所在,有人可以帮助我吗?

You have a Connection timed out error, so we can say that: 您有一个Connection timed out错误,所以我们可以这样说:

  • since this is not an Unknown host error, you must have a DNS that gives an IPv4 or IPv6 address for www.google.com 由于这不是Unknown host错误,因此您必须具有一个DNS,该DNS可以为www.google.com提供IPv4或IPv6地址
  • since this is not a destination unreachable error, you have a route to a gateway and this gateway is a local router that has a default route. 由于这不是destination unreachable错误,因此您具有到网关的路由,并且该网关是具有默认路由的本地路由器。

Therefore, the timeout for connect means you have sent a TCP SYN packet to a destination, and this packet has been dropped somewhere in your local network or at the interface between your network and the Internet, in a firewall (since you have not received any ICMP/ICMPv6 packet saying something was wrong - a standard router should have sent you such an information). 因此, connect超时意味着您已将TCP SYN数据包发送到目标,并且此数据包已被丢弃在本地网络中或网络与Internet之间的接口中的防火墙中 (因为尚未收到任何内容)。 ICMP / ICMPv6数据包说出了问题-标准路由器应该已经向您发送了此类信息)。

The problem is with the first packet (TCP SYN), so your problem can not be relative to your addHeader() calls in your source code. 问题出在第一个数据包(TCP SYN)上,因此您的问题不能与源代码中的addHeader()调用有关。 Those headers are never sent, in your case, with this error. 在您的情况下,这些头永远不会因此错误而发送。

Since www.google.fr has IPv4 and IPv6 addresses, there are two possibilities: 由于www.google.fr具有IPv4和IPv6地址,因此有两种可能性:

  • either you have a local IPv6 router that sends RA advertisments, but is not connected to the Internet with IPv6. 要么您有一个本地IPv6路由器发送RA广告,但没有通过IPv6连接到Internet。 Try this to check this case: 试试这个检查这种情况:

replace: 更换:

https://www.google.com/recaptcha/api/siteverify?secret=XX&response=XXX

by: 通过:

https://[2a00:1450:400c:c04::6a]/recaptcha/api/siteverify?secret=XX&response=XXX

If you continue to get a timeout , this means you have an IPv6 router that is badly configured. 如果继续timeout ,则意味着您的IPv6路由器配置错误。

  • or you have a firewall and need to use a proxy 或者您有防火墙并且需要使用代理

replace: 更换:

https://www.google.com/recaptcha/api/siteverify?secret=XX&response=XXX

by: 通过:

https://74.125.206.104/recaptcha/api/siteverify?secret=XX&response=XXX

If you continue to get a timeout, this means you have a firewall and should use a proxy. 如果继续超时,则意味着您有防火墙,应使用代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM