0

So I built an app on App Engine that takes users files and move them to certain folders in the same domain. I made REST api that calls Drive API to list files, rename files, and change permissions etc.

On app load, it fires 4 ajax calls to the server to get name and id of folders and checking if certain folder exists.

The problem is front end ajax calls time out all the time in production. App engine url fetch has 60 sec limit. I used App engine's oauth2 library which uses a different httplib2. So I modified httplib2 source deadline to max 60 sec but it seems to time out after 30 sec. As a result, Drive API calls time out almost every time and app just doesn't work.

I have read the guideline on optimizing drive api calls with partial response and implemented it but didn't see noticeable difference. It's driving me crazy.... please help

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
user1297061
  • 1,531
  • 2
  • 13
  • 15

1 Answers1

0

You mention "AppEngine's oauth2 library", but then you say "Drive API calls time out". So modifying the Oauth http library won't affect Drive.

Are you using the Google library for your Drive calls, or making direct REST HTTP calls?

If the former, try ...

HttpRequest.setConnectTimeout(55000)

, if the latter just ...

request.getFetchOptions().setDeadline(55d)

NB. Drive is having a brain fart today, so one would hope the underlying problem will go away of its own accord.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • Hi thank. Drive API was indeed having problem the other day. Today is back to normal. And sorry, should have made it clearer. I'm using the app engine Oauth python sdk, which has a [oauth_required decorator](https://developers.google.com/api-client-library/python/guide/google_app_engine) that handles all the Oauth2 steps automatically for request handler it attaches to. Therefore, I didn't have to make http object anywhere and also didn't set the time out. I didn't find `HttpRequest.setConnectTimeout(55000)` in the Oauth libray. app engine has different oauth libary – user1297061 Feb 11 '14 at 05:04
  • I search `deadline` in the library and the only place I found it is inside a function called `_new_fixed_fetch` which returns a fetch function `fetch(url, payload=payload, method=method, headers=headers, allow_truncated=allow_truncated, follow_redirects=follow_redirects, deadline=60,validate_certificate=validate_certificate)` The deadline was initially set to 5 sec and I changed it to 60 but it seems to time out before 60 sec. Does Drive have a limit it sets itself that returns 500 after certain time? – user1297061 Feb 11 '14 at 05:07
  • If Drive returns a 500, that usually means something has screwed up within the API/Drive infrastructure. Often it's an internal timeout between different servers within G. It's retryable after an exponential backoff. Occasionally it can be caused by your code triggering one of the bugs that you can search for on SO. Sorry I don't know Python to help you configure the timeouts. – pinoyyid Feb 11 '14 at 05:30
  • cool, thanks. I guess it's mostly G's problem than mine. Glad things are back to normal today. – user1297061 Feb 11 '14 at 05:51
  • Look on the bright side, it's a great opportunity to test your app's error handling :-) – pinoyyid Feb 11 '14 at 07:53
  • haha, totally, it was a learning experience. I changed ajax code to automatic retry after fail, so now it's more robust. Also in my server code I have consecutive Drive API calls using the results of the previous ones as input. The slow drive calls means it breaks in the middle I have no way to roll back. Probably should separate them. Most importantly, if I were to make another little app that manipulate drive stuff inside one google app domain I would go with app script and avoid this authentication and url fetch mess all together. Although app script isn't documented. thanks again. :D – user1297061 Feb 11 '14 at 08:31