googleapis / google-api-php-client

A PHP client library for accessing Google APIs
http://googleapis.github.io/google-api-php-client/
Apache License 2.0
9.35k stars 3.53k forks source link

Failed to connect to oauth2.googleapis.com port 443: Connection timed out #1749

Closed pdeberranger closed 4 years ago

pdeberranger commented 4 years ago

We are using the google api with php to authenticate our user. Since one week we have a lot of : Failed to connect to oauth2.googleapis.com port 443: Connection timed out. If we refresh it's works, but 1 of 2 time it's timed out.

What can i do ?

PHP Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: cURL error 7: Failed to connect to oauth2.googleapis.com port 443: Connection timed out (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in /var/www/fr/my.isartintra/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:200\nStack trace:

$this->GoogleClient = new \Google_Client(); $this->GoogleClient->setClientId($this->Client_id); $this->GoogleClient->setClientSecret($this->Client_secret); $this->GoogleClient->setRedirectUri($this->Redirect_uri); $this->GoogleClient->setScopes(['email', 'https://www.googleapis.com/auth/calendar.events.readonly']); $this->GoogleClient->setAccessType('offline'); $this->GooglePlus = new \Google_Service_Oauth2($this->GoogleClient);

We use GooglePlus to get the picture $user_name = $this->GooglePlus->userinfo->get()->name; $user_email = $this->GooglePlus->userinfo->get()->email; $user_google_picture = $this->GooglePlus->userinfo->get()->picture;

Many thanks for help.

tmatsuo commented 4 years ago

@pdeberranger

Let me start with asking some questions.

What kind of environment you're running the code? Is it possible that the environment has a poor network connection, or the network bandwidth is pretty full at the moment?

Is this reproducible on other environment?

pdeberranger commented 4 years ago

We have two types of environments: Workstation (dev) Servers Tests were performed from several 4G, 600Mb, 2Gb network links

Since 26/11, the service seems to have been restored, we have not changed anything and we no longer have timeout.

tmatsuo commented 4 years ago

@pdeberranger Thanks for the update!

I guess it was due to the backend issue. While such issues on the auth backend are problematic, I don't think there's anything we can do within our client library to improve things.

Let me close this, but feel free to open if you think differently.

Thanks again.

paslandau commented 4 years ago

@tmatsuo

We're seeing similar issues from time to time as well. The problems usually persist for a couple of minutes but can also span hours to days with sporadic errors like:

In rare cases, we've also seen misleading errors like "Invalid project ID ''. Project IDs must contain 6-63 lowercase letters, digits, or dashes. [...]" that hint to a client error but actually originated on the backend (see https://github.com/googleapis/google-cloud-php/issues/1673)

Though I realize there's not much the client lib can do (apart from retrying), it would be great to have an "official place" where such errors are tracked - especially for intrenal stakeholder communication.

I'm aware of https://status.cloud.google.com/ but that doesn't seem to pick up on more subtle outages.

Im currently resorting to Twitter, but that hardly feels like a good fit in terms of transparency, e.g.

ernst77 commented 2 years ago

I am having the same issue, it appears when many request are being sent... So the best solution is to retry until it dissapears?

akash5100 commented 2 years ago

I am facing the same issue. Which is Error: HTTPSConnectionPool(host='oauth2.googleapis.com', port=443), until last day it was working just fine. All I have to do is keep retrying?

pinkasey commented 2 years ago

I got this issue today, for 3 hours. Go this:

cURL error 28: Failed to connect to oauth2.googleapis.com port 443 after 75200 ms: Connection timed out (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://oauth2.googleapis.com/token

@odedstr FYI

badams2527 commented 2 years ago

We're still being affected by this intermittently. It prevents our APIs from creating pubsub messages for an irregular amount of time. Any workarounds for this besides adding retry logic?

odedstr commented 2 years ago

We had this issue recently and it was solved by the hosting provider. The problem was that some of the Google IP addresses were blocked by the hosting provider's Firewall, after our server tried to send too many simultaneous API calls to these IP addresses. They solved it by removing the blocks, and increasing the max number of allowed connections.

badams2527 commented 2 years ago

Interesting, thanks. In this case that's super concerning considering we're getting this error from our containers in GKE :D I'll contact GCP support and see if there's anything they can do. Thanks for the response!

wenshan commented 8 months ago

I have the same problem

Daudxu commented 6 months ago

Error exchanging code for tokens: GaxiosError: request to https://oauth2.googleapis.com/token failed, reason: connect ETIMEDOUT 172.217.160.74:443 at Gaxios._request (C:\Users\xudan\Desktop\test\node_modules\gaxios\build\src\gaxios.js:143:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async OAuth2Client.getTokenAsync (C:\Users\xudan\Desktop\test\node_modules\google-auth-library\build\src\auth\oauth2client.js:137:21) at async C:\Users\xudan\Desktop\test\server.js:29:24 { config: { retry: true, retryConfig: { httpMethodsToRetry: [Array], currentRetryAttempt: 2, retry: 3, noResponseRetries: 2, statusCodesToRetry: [Array] }, method: 'POST', url: 'https://oauth2.googleapis.com/token', data: '< - See errorRedactor option in gaxios for configuration>.', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'google-api-nodejs-client/9.8.0', 'x-goog-api-client': 'gl-node/18.18.2' }, paramsSerializer: [Function: paramsSerializer], body: '< - See errorRedactor option in gaxios for configuration>.', validateStatus: [Function: validateStatus], responseType: 'unknown', errorRedactor: [Function: defaultErrorRedactor] }, response: undefined, error: FetchError: request to https://oauth2.googleapis.com/token failed, reason: connect ETIMEDOUT 172.217.160.74:443 at ClientRequest. (C:\Users\xudan\Desktop\test\node_modules\node-fetch\lib\index.js:1501:11) at ClientRequest.emit (node:events:517:28) at TLSSocket.socketErrorListener (node:_http_client:501:9) at TLSSocket.emit (node:events:517:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { type: 'system', errno: 'ETIMEDOUT', code: 'ETIMEDOUT' }, code: 'ETIMEDOUT',

}

DunZane commented 5 months ago

same problem😭: Post "https://oauth2.googleapis.com/token": dial tcp 172.217.160.74:443: i/o timeout

shakhbozmn commented 5 months ago

got error: RNGoogleSignInError: The user canceled the sign in request., Error Domain=org.openid.appauth.general Code=-5 "Connection error making token request to 'https://oauth2.googleapis.com/token': A server with the specified hostname could not be found.." UserInfo={NSLocalizedDescription=Connection error making token request to 'https://oauth2.googleapis.com/token': A server with the specified hostname could not be found.., NSUnderlyingError=0x600000c60ed0 {Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=8, NSUnderlyingError=0x600000dd0480 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, _NSURLErrorNWResolutionReportKey=Resolved 0 endpoints in 1ms using unknown from cache, _NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], uses wifi}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <0B388E1A-3ED5-4BA9-8085-71265BDA679C>.<6>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask .<6>" ), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://oauth2.googleapis.com/token, NSErrorFailingURLKey=https://oauth2.googleapis.com/token, _kCFStreamErrorDomainKey=12}}}

this is happened when i try to run my app when i change the host in firebase emulators for local testing, but i fixed the issue by rebuilding the app for ios, using npm run ios