I'm trying to implement google sign-in in my website that is written in Symfony2 using Google Client API. I followed the instructions here, but when I call $client->authenticate($code); command an exception is thrown telling that:
Failed to connect to www.googleapis.com port 443: Network unreachable
What is the problem?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Try this echo ipv4 >> ~/.curlrc. It Worked for me.
If your network under proxy. You should set the proxy url and port
This is solves my problem
Had the same issue - problem was with dns resolution, like mentioned in le0diaz's answer.
On ubuntu 16.04, we were able to solve it by chaning /etc/gai.conf, changing the presedance for IPv6, uncommenting the following line: precedence ::ffff:0:0/96 100
Looks like an outgoing firewall/proxy/network issue. You should be able to verify that using
ping
andcurl
from the machine where your website runs.Solution 2 (from update). it seems to be some bug with ipv6 interfaces and curl with php, so another solution is to set the appropiate option in curl function to connect to the remote server with ipv4 in your php script
curl_setopt( $curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
Solution 1.
The same happened to me (solved by adding the ip v4 and hostname to /etc/hosts file), As pointed by @hans-z in another answer comment, I tried using next command to validate the network issue.
It turned out that it was randomly, and only 1 in 10 tries the curl command could connect to the server, the response was something like: ("La red es inaccesible" means in english "network unreachable" :) )
And the successfull response was:
The weird message was "Hostname was NOT found in DNS cache", I was using google DNS's 4.4.4.4 and 8.8.8.8, so I added that domain to my /etc/hosts file using the ipv4 from the curl command output and the problem was solved.