Timeouts refreshing Google oauth token in GAE app - google-app-engine

I have a GAE app that periodically requests a user's activities from G+. I'm using the google oauth client api for java.
This has been working fine for months with literally no code changes (I'll post the code if required, it's all taken straight from the oauth client project examples, using GoogleAuthorizationCodeFlow).
However, a couple of days ago this changed. Now, without fail from the GAE instance, I get this exception during token refresh:
java.net.SocketTimeoutException: Timeout while fetching URL: https://accounts.google.com/o/oauth2/token
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:141)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:43)
at com.google.api.client.extensions.appengine.http.UrlFetchRequest.execute(UrlFetchRequest.java:77)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1009)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:299)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:323)
at com.google.api.client.auth.oauth2.Credential.executeRefreshToken(Credential.java:586)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:505)
at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:266)
Now this still works fine from my local machine. There are no reported quota issues on the GAE dashboard or on the Google APIS console for this app. Billing is enabled for the Google APIs console project, but not the GAE app.
I note there's a similar looking issue in a python app reported here, but that has no responses so far.
This has been happening continuously for a couple of days - the app tries once an hour for a hundred or so different users. If I limit the app to only perform this for a single user it still occurs.

Here is what I've noticed:
the service started working for me two days in a row at about 10:30 pm and then stopped working again next day at about 8am(both Saturday and Sunday this weekend: June 8-9 2013). Really looks like high load issue.
Will hope that Google fix it soon.
I absolutely made no changes in my code on app engine server. It just started working and then stopped working.
P.S. also it looks like it takes always about 40 seconds before server gets SocketTimeoutException every time I try to sign in with Google plus.
P.P.S. and yes it works on my local instance of Google App Engine.

We are still experiencing the same problem: at around 1pm-2pm GMT of every day the OAuth2 refresh token method starts failing with a time out error, for 10-14 ours. After that time it works again.
A similar issue is posted here: https://code.google.com/p/google-glass-api/issues/detail?id=99.
Lorenzo
Update: it seems the problem has been solved.
See https://groups.google.com/forum/?fromgroups#!topic/google-appengine-downtime-notify/TqKVL9TNq2A

I think it may have been due to this issue:
The problem with Google App Engine URL Fetch service to Google
Accounts authentication endpoints was resolved as of 5:15 PM
US/Pacific on June 7, 2013. We apologize for the inconvenience and
thank you for your patience and continued support. Please rest assured
that system reliability is a top priority at Google, and we are making
continuous improvements to make our systems better.
https://groups.google.com/forum/?fromgroups#!topic/google-appengine-downtime-notify/TqKVL9TNq2A

This timeout issue is happening consistently for on two app engine instances running my app anyCloud and staging.anycloud.co). I can not get an access token or refresh an existing one and consistent with the other posters, the same code works fine when running in a localhost dev environment.

Related

Getting a 504 Gateway Error on Google App Engine (long runtime of Flask App)

I have been working with Google Cloud Platform & Flask for the first time - my client wanted me to deliver a solution on it in 2 weeks.
I have been successful so far in creating a Flask application and wanted to productionize it through Google App Engine. However, the runtime of my function is a little over 2.5 minutes and I get a "504 Gateway Timeout" error. In the code piece, I am accessing bigQuery, google spreadsheets and GCS buckets. Should I switch to a new GCP service or can some tweaks in my code/yaml file suffice? My yaml config is -
runtime: python37
liveness_check:
check_interval_sec: 300
timeout_sec: 299
failure_threshold: 10
success_threshold: 10
initial_delay_sec: 500
readiness_check:
app_start_timeout_sec: 1800
I would be very, very grateful to anyone who can help me resolve this issue.
Thank you!
Edit: Just to give a brief about the application - this is a forecasting application that reads data from bigquery, GCS buckets, and Google Spreadsheets, processes it and runs ML models on it. The results are written back to Google Spreadsheets within the application itself (i.e. no response needed from the application per see). I'm triggering the application using google AppsScript.
The best option is to restructure how your website works. You can then stick with GAE standard. Even if you switch to GAE flexible, it will work better this way.
Here is the sequence of operations:
A user submits a request from web page.
Your website returns immediately with a page that indicates that you are working on it.
The page you return includes Javascript that will poll your website to ask if the task is complete.
When the task is complete, the Javascript will update the page and present the results to the user.
On the server side, you can use cloud tasks for doing the processing which I believe has a time limit of 10 minutes.
This way, the user is always viewing a web page and isn't sitting there waiting and looking at a blank screen while waiting for the server to return something.

can't deploy Google Cloud Endpoints 2.0 on existing service

I have had a Python-based Google App Engine app working great using Cloud Endpoints 1.0 for several years without incident. I have had nothing but trouble migrating to Cloud Endpoints 2.0.
Currently I'm in the following state after already clearing many previous hurdles described in other similar questions:
I have one version of my service called gce1 which uses Endpoints 1.0 and is set as the default service receiving 100% of my traffic. I can point API clients and the APIs Explorer to both gce1-dot-myservice.appspot.com and the default myservice.appspot.com and everything works fine. I can verify in the logs that anything that goes through here is using GCE 1.0.
I have a second version of my service called gce2 which is not receiving any traffic by default, but if I point an API client or the APIs Explorer to gce2-dot-myservice.appspot.com it works just fine, and I can verify in the logs that anything that goes through here is using GCE 2.0.
Great, right? So it would seem that all I need to do is migrate all my traffic to gce2 and I'm done.
But... when I do that everything breaks! The default myservice.appspot.com serves up 405 POST Method Not Allowed responses to my existing clients, and if I look at the APIs Explorer, suddenly it now shows a bunch of obsolete methods that I think are from years ago and are no longer used in my current API. I can't tell where those are coming from (they are nowhere in my code, and haven't been for years), and I can't get the default service to serve the GCE 2.0 API no matter what I do.
The biggest problem is that I have thousands of users in the wild that all point to the default API URL, so it isn't so easy to just have them start pointing to gce2-dot-myservice, and besides, it doesn't make sense that I can't make the new default the new default. I've been working on this migration to GCE 2.0 for months, the deadline for getting off GCE 1.0 is getting closer by the day, and Google Support has not responded since late last year on this topic.
I should also mention I have tried:
Pushing a new service with the GCE2.0 code directly to default
Pushing a new service with no API at all (to maybe clear a cache or something)
Pushing services with all different sorts of version names
None of these have worked, although I haven't done any of them allowing a long delay since I'm working on a live service with real users.
This issue is now resolved, so for most people it should no longer occur. However, in my specific case, I had a legacy API that was getting in the way and had to be deleted, which did require specific attention from a Google engineer.
If you have similar issues, visit issuetracker.google.com/issues/76031966 and comment there.
Thanks to #saiyr for help tracking this down.

GAE not starting

i can;t deploy app to GAE anymore.
App deploy was always stuck with time out.
Some days ago app was working fine. I was able to deploy. I'm sure.
I pickup old version, just to eliminate possibility that something wrong with app
I try to deploy with all reasonable parameters.
I try delete all services (except default which i can't delete, however i uploaded basic one line app)
I already try most of advice which i found on web
I try to disable App engine.. It failed, however after some time i was able to Disable it.
Now i'm not able to enable GAE.. i see folowing error:
ERROR: (gcloud.app.deploy) Unable to deploy to application [**************] with status [USER_DISABLED]: Deploying to stopped apps is not allowed.
Any advice is welcome:
- How to enable GAE
- How to avoid time outs during deploy App to GAE
Thanks a lot
The public issue tracker is a good place to put bugs and/or feature requests. For faster and more urgent issues, contact the Google Cloud Platform support team directly and they will be able to assist you.
Your issue could also simple be a propagation delay, so if in 24/48 hours and you still can't, then it's likely a bug. Furthermore, you can always deploy to another project if it's all the same to you.

App Engine Error when try to make Google OAuth in high traffic site - CRITICAL

I have a site with options of Login with Google and Facebook.
My site has near 200 users and many of them make their logins at 13:00 hrs (Chilean Time).
Today we have a very critical error, when making the loging, we received the Google OAUTH 2 token response and when trying to get the user profile using this url:
https://accounts.google.com/o/oauth2/token?.... (my app secret, token, etc)
The Google system started to answer with an error (this error was visible only in the urlfetch response of the app engine python app):
"We're sorry...
... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.
See Google Help for more information."
I have been using the system for more than a year without problems but today, without any change in the code, started receiving this error during 15 minutes and make our system totally freezed due to nobody can login...
How can I prevent this doesn't happen again in the future? If the google OAuth cant' support more than 200 users loging in in 1 minute I think is useless!!!! I decided to make pur app in app egine for scalability, but this issue make me think again...
Thank you
Rene Marty
this may be related to an App Engine authentication issue tracked here: https://status.cloud.google.com/incident/appengine/15006

Google App Engine quota reached on test site. What am I doing wrong?

First off, I'm totally new to GAE. 3 days ago I did a search on Google for hosting a website on Google App Engine for free. I found this tutorial on labnol.org:
http://www.labnol.org/internet/host-website-on-google-app-engine/18801/
I was under the impression that GAE's quota for free users was high. My site has received very little traffic. At best, the site is getting 50 daily page views, of which most, if not all, are mine. I'm testing my code on and refreshing my browser.
GAE indicates the following: Frontend Instance Hours - 100% - 28.00 of 28.00 Instance Hours
I made no adjustments to my GAE settings UNTIL this morning. 2 things changed in the last 12 hours:
I changed my frontend instance class from the default f1 to f4. My reason for doing so was to see if it would improve my site's loading time (it didn't). My site is a fairly small and simple site.
I replaced the html files and images from the last 2 days with fresh ones this morning. Doing this resulted in my making some changes to files and uploading (deploying via GoogleAppEngineLauncher Mac app) changes probably about 5 times per hour.
On my settings page everything is at 0, with the exception of this one:
Frontend Instance Hours 100% 28.00 of 28.00 Instance Hours
How did I reach the hosting quota for GAE? Should I adjust any other settings? What can I do to prevent this from happening in the future?
Additional facts:
The size of the folder containing all my files is 38kb in size.
I have Google Analytics, by way of Javascript, running on index.html (none of the other pages).
I'm using raw, basic, html.
my pages consist of approximately 3kb of image data being served per page.
Thanks
If your website consists of largely static content, I highly recommend you implement Frontend Caching. This should drastically cut down your instance hours as the majority of it would be served off Google's frontend servers.
For every page that's served from cache, you'll see a 204 logged in AppEngine. See also this talk on scaling GAE apps.
Note that there's also the option of using memcache within your app, but briefly looking at that tutorial link, I suspect this won't apply to you.
I changed my frontend instance class from the default f1 to f4.
F4 class instances consume hours 4 times faster. Your 28 hour quota will get exhausted every 7 hours.
If you're using that much instance time serving 50 static pages, I'd guess that your idle instance setting is set at 1 or more (which would make the app run all day even when no one is using it). Make sure that on your application settings page the "idle instances" slider is set at "automatic-1".
He will not be able to adjust his Idle Instance setting until enabling billing.

Resources