503 Service Unavailable

2,160 views
Skip to first unread message

Kevin

unread,
Feb 4, 2012, 12:45:29 PM2/4/12
to Google Calendar API
Hi,

I've been using the Calendar API and today I started getting the
following error:
503 Service Unavailable
{
"code" : 503,
"errors" : [ {
"domain" : "global",
"message" : "Backend Error",
"reason" : "backendError"
} ],
"message" : "Backend Error"
}

The only thing I changed was instead of hitting one of my calendars
(with very few events, on purpose, for testing) to another one of my
calendar (that has many more events, on purpose, for testing calendars
with more events). It seems that the number of events I'm querying is
what is causing this error. The widest date range that I ever query is
a 2 week window. However, there could be 10-20 events per day. So,
roughly 200 events could be returned in a query. On my calendar with
fewer events, the most events in a 2 week window is about 20-30.
Is this a bug on the Google Calendar side or am I doing something
wrong in my code to get this error?

Kevin

unread,
Feb 10, 2012, 1:56:17 PM2/10/12
to Google Calendar API
bump...any ideas?

Alain Vongsouvanh

unread,
Feb 13, 2012, 12:24:46 PM2/13/12
to google-ca...@googlegroups.com
Hello Kevin,

Unfortunately, a 503 means a temporary error in our backend which should resolve by itself over time. However, if you manage to reproduce this error all the time, it would be really useful for us if you could post the request you send to the API so that we can look into it.

Best,
Alain

bump...any ideas?
--
You received this message because you are subscribed to the Google Groups "Google Calendar API" group.
To post to this group, send email to google-ca...@googlegroups.com.
To unsubscribe from this group, send email to google-calendar...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-calendar-api?hl=en.




--
Alain Vongsouvanh | Developer Programs Engineer

Kevin

unread,
Feb 14, 2012, 11:06:32 PM2/14/12
to Google Calendar API
I figured it out. I was calling the API incorrectly, in my opinion,
which lead to the error. So, mostly my fault; partly the API for not
stopping me from doing it wrong.

Using the coding example from the developer's guide:

http://code.google.com/apis/calendar/v3/using.html#retrieving_events

I initially called the execute with a bunch of conditions:

Events events =
service.events().list(calendarId).setTimeMin(timeMin).setTimeMax(timeMax).setSingleEvents(true).setOrderBy("startTime").execute();

then, later on, after checking for the next page token (see the code
example from the developer's guide), I forgot to mimic the same
conditions, and I called something like the default from the coding
example from the developer's guide:

service.events().list(calendarId).setPageToken(pageToken).execute();

that's the line it was failing on...if I match up the conditions where
I set the page token to my earlier call, it works and I don't get the
503 error. Another solution was to set the maxResults to a high enough
value. This solution was more appropriate for my situation and the way
that I fixed the problem. FYI, the default page size is 100. I don't
know if it's like that ever ytime or for everyone, but it was 100
every time I checked it.
I hope this helps others having the same problem and you, Alain, to
troubleshoot this from your side to see if you can get the API to
return something other than a 503.

Howard Smith

unread,
Apr 9, 2013, 11:12:43 PM4/9/13
to google-ca...@googlegroups.com
Alain,

On Monday, February 13, 2012 12:24:46 PM UTC-5, Alain Vongsouvanh wrote:

Unfortunately, a 503 means a temporary error in our backend which should resolve by itself over time.

You are right, 503 should resolve itself over time, but I will tell you my experience today.

I'm running my JSF web app via TomEE 1.6.0 snapshot (Tomcat 7.0.39), and dates are queued in an array, in my app, as endusers modify data related to certain dates (tour bus company software). To avoid too/so many updates to Google Calendar (since google calendar limits # of requests in a certain amount of time), as endusers are making tons of edits on calendar-based-data, I developed software that will strategically update google calendar with data via home-made timer software i developed within the app, and use of @Singleton @Schedule, and JMS (Apache ActiveMQ).

Anyway, the latest version of the google-calendar-update-software that I developed, in the web app, has been running pretty well for the last week or so; i have had to tweak the code numerous times to get it to run stable with google calendar API (v3) (delete events via retries and then add events to target date on the calendar). The many tweaks (over some # of months, off and on) has finally resulted in no 'duplicate events' on the calendar, since sometimes, dates are updated at different points in time (and at anytime in the future, for whatever reason).

So, today, I checked the server/error log to see how well the app was performing, and I saw 503 error code that occurred while event was being added to calendar, and then I saw that 2 different dates (3/1/2013 and 3/13/2013) had 'google-calendar-error', so those dates were re-added to queue (List<>), and @Schedule attempted to update google calendar with those dates (one-at-a-time), every 2 minutes. The error/server log only showed 503 error (json exception), once, in the log, but afters, the app just logged 'error' with no details. :(

So, since the 'error' was not correcting itself, I decided to shutdown the app server (tomee), and restart the app server, and then I opened Google-Calendar-Utililty page in the web app, which allows me to select dates, and google calendar will be updated with data related to the selected dates. So, I selected 3/1/2013, google calendar was updated successfully (without error 503), and then I selected 3/13/2013, and google calendar was updated successfully (without error 503).

I looked at audit trail in the app, and the data has not been changed that should have populated the 'addevent' request to google calendar.

However, if you manage to reproduce this error all the time, it would be really useful for us if you could post the request you send to the API so that we can look into it.


So, my next to-do tonight/now, is to log more details about the addEvent request as per what you mentioned above. maybe there was something terribly wrong with the request. I know I recently added eclipselink caching/query-hints/etc in/throughout the app, for performance reasons, maybe-just-maybe, the request either had a null value, or a bad 'location', as I do populate 'location' of the event, because my brothers love the Google Calendar feature that sends notification to Android devices and google calendar web-app notification that it is 'time to leave... to arrive at this location'. :)

Anyway, a big FYI... this error 503 occurred on a date that had many events. I may need to do what Kevin did/recommended in his last/latter response in this thread. Honestly, my addevent method is not doing any delete events. I delete events, first, in a loop with retries, until all events are deleted, and then I re-add events for the calendar date. The 'duplicate events' issue, that I mentioned earlier, always occurred on dates with many events, too. Today, I thought my app was running well, but enduser made some changes to data on a date with many events, the app attempted to update google calendar, accordingly, but error 503 was the result. I think this is the first time that I seen 503, and definitely the first time I seen my app, infinitely, attempt to update certain date(s) on calendar, result in error, and this behavior repeats every 2 minutes via @Schedule.

I am thinking of logging requests that resulted in error 503, and then 'not' re-add the 'date' back to the queue. Ultimately, it might be best for me to get a fresh new set of data and populate the 'addevent' request, accordingly, when error 503 occurs.

Thinking out loud. :)

Howard
 

Howard Smith

unread,
Apr 9, 2013, 11:14:47 PM4/9/13
to google-ca...@googlegroups.com
Thanks Kevin. I'm going to study your response below and study my code a bit, and see what I can do to develop some type of workaround for the 'sporadic'/unexpected 503 error code. :)
Reply all
Reply to author
Forward
0 new messages