我试图在我的网站上使用Google Client API在Symfony2中编写Google登录。我遵循指示here,但是当我调用$ client-> authenticate($ code);命令抛出异常告诉:
无法连接到www.googleapis.com端口443:无法访问网络
问题是什么?无法连接到www.googleapis.com端口443:无法访问网络
回答
看起来像一个传出的防火墙/代理/网络问题。您应该能够验证在您的网站运行的机器上使用ping
和curl
。
我在本地主机上测试它。这是问题吗? – 2015-02-06 16:03:50
尝试'curl -v https:// www.googleapis.com'并查看它报告的内容 – 2015-02-06 17:06:38
我尝试使用我的VPS并打印404 Not Found响应。 – 2015-02-06 18:43:11
解决方案2(来自更新)。 它似乎是与IPv6接口的一些bug,并使用PHP卷曲,所以另一种解决方案是设置在卷曲功能此时,相应的选项,使用IPv4连接到远程服务器在你的PHP脚本
curl_setopt($卷曲,CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
解决方法1.
同样的事情发生在我(通过将IP v4和主机名解决了/ etc/hosts文件),作为另一个答案评论指出通过@汉斯-Z,我尝试使用下一个命令来验证网络问题。
原来,这是随机的,只有在10名试图1 curl命令可以连接到服务器,该反应是这样的: (“拉红色ES inaccesible”在英语中的“网络不可达指“:))
$ curl -v https://www.googleapis.com
* Rebuilt URL to: https://www.googleapis.com/
* Hostname was NOT found in DNS cache
* Trying 64.233.186.95...
* Trying 2800:3f0:4003:c00::5f...
* connect to 2800:3f0:4003:c00::5f port 443 failed: La red es inaccesible
* Failed to connect to www.googleapis.com port 443: La red es inaccesible
* Closing connection 0
curl: (7) Failed to connect to www.googleapis.com port 443: La red es inaccesible
而且全成反应是:
curl -v https://www.googleapis.com
* Rebuilt URL to: https://www.googleapis.com/
* Hostname was NOT found in DNS cache
* Trying 64.233.186.95...
* Trying 2800:3f0:4003:c00::5f...
* Connected to www.googleapis.com (64.233.186.95) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES128-GCM-SHA256
* Server certificate:
* subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.storage.googleapis.com
* start date: 2015-04-08 14:12:01 GMT
* expire date: 2015-07-07 00:00:00 GMT
* subjectAltName: www.googleapis.com matched
* issuer: C=US; O=Google Inc; CN=Google Internet Authority G2
* SSL certificate verify ok.
> GET/HTTP/1.1
> User-Agent: curl/7.35.0
> Host: www.googleapis.com
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: Fri, 01 Jan 1990 00:00:00 GMT
< Date: Tue, 21 Apr 2015 21:38:12 GMT
< Vary: X-Origin
< Content-Type: text/html; charset=UTF-8
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
* Server GSE is not blacklisted
< Server: GSE
< Alternate-Protocol: 443:quic,p=1
< Accept-Ranges: none
< Vary: Origin,Accept-Encoding
< Transfer-Encoding: chunked
<
* Connection #0 to host www.googleapis.com left intact
是怪异的消息‘主机名未在DNS高速缓存中找到’我使用谷歌DNS的4.4。 4.4和8.8.8.8,所以我使用curl命令输出中的ipv4将该域添加到我的/ etc/hosts文件中,问题已解决。
#/etc/hosts
...
64.233.186.95 www.googleapis.com
#DONT COPY THIS IP, USE THE ONE FROM YOUR CURL OUTPUT
...
这立即解决了我尝试连接到** Google GCM API **时遇到的超时问题我的本地开发 - MAMP与Apache/2.2.29,PHP 5.6.10和curl 7.41.0。 奇怪的是,并非所有请求都超时。许多人虽然。 感谢您的帮助! – 2015-12-10 02:54:26
如果在代理网络。你应该设置代理地址和端口
curl_setopt($ch, CURLOPT_PROXY, "http://url.com"); //your proxy url
curl_setopt($ch, CURLOPT_PROXYPORT, "80"); // your proxy port number
这是解决我的问题
试试这个回声的IPv4 >>〜/ .curlrc。 它为我工作。
这应该是一个评论,而不是一个答案! – 2017-06-16 10:26:33
对不起Div我无法评论这就是为什么我回答 – 2017-06-19 12:28:00
有同样的问题 - 问题是与DNS解决问题,就像在le0diaz的答案中提到的。
在Ubuntu 16.04中,我们能够通过chaning /etc/gai.conf,改变对IPv6的presedance,取消注释以下行来解决这个问题: 优先:: FFFF:0:0/96 100
- 1. 无法连接到bitbucket.org端口443:网络无法访问
- 2. Git to GitHub - 无法连接到端口443:连接被拒绝
- 3. 无法连接到graph.facebook.com端口443:连接被拒绝
- 4. 无法推 - 无法连接到github.com 443端口:连接被拒绝
- 5. 无法获取tokenresult oauthClient.ExchangeCodeForAccessToken;无法访问的网络69.171.229.24:443
- 6. 无法连接到github.com端口443:操作超时
- 7. Android - 在10000ms后无法连接到settings.crashlytics.com/54.83.49.38(端口443)
- 8. Mac终端无法连接网络
- 9. cURL错误7:无法连接到api.keen.io端口443:连接超时
- 10. Facebook SDK返回错误:无法连接到graph.facebook.com端口443:连接被拒绝
- 11. 连接到网络时无法访问Web服务:: HTTP 407
- 12. 网络无法访问?
- 13. IOException网络无法访问
- 14. 无法从客户端连接到网络上的方法asp.net
- 15. Dataplicity无法访问端口
- 16. Docker无法访问端口
- 17. Python端口检查器 - 无法访问的网络
- 18. Mikrotik路由器端口转发 - 无法从网络访问
- 19. IIS 10无法绑定端口443
- 20. 无法连接到特定的网络接口
- 21. 无法连接到端口80
- 22. 无法连接到端口7
- 23. 广东话推git的,无法连接网址:443无错
- 24. curl:(7)无法连接到端口80和443 - 在一个域上
- 25. 无法连接到Gcloud内部网络中的其他VM端口
- 26. Windows:无法连接到sysname:地址(无法连接到主机/端口)epmd(端口4369)
- 27. 使用端口443连接到Heroku
- 28. 连接到无线网络
- 29. howdoi无法建立网络连接howdoi
- 30. Android无法连接网络服务器
检查你的firewalre配置plesae看到这个http://stackoverflow.com/a/39590519/2652524 – 2016-09-20 09:46:13