I'm using Calendar API client library for Java to watch channels and get push notifications. Sometimes, when I try to create a channel on Google, it returns the following error response:
{
"code" : 503,
"errors" : [ {
"domain" : "global",
"message" : "Failed to create channel",
"reason" : "backendError"
} ],
"message" : "Failed to create channel"
}
There is nothing about handling this error in the documentation:
https://developers.google.com/google-apps/calendar/v3/errors
However, I guess it could happen due to high number of request are sent to Google and it refuses the connection. Maybe, here I need to perform retry after some time. The question is what's the correct way to handle this error and to start watching the desired channel?
答案 0 :(得分:2)
The route cause of this issue is probably a heavy network traffic. Google calendar API suggests the solution of exponential backoff implementation for that kind of errors.
An exponential backoff is an algorithm that repeatedly attempts to execute some action until that action has succeeded, waiting an amount of time that grows exponentially between each attempt, up to some maximum number of attempts.
You could find implementation ideas here.