YouTube V3 API - Google.Apis.Requests.RequestErrorBackend [503] Error

Error backend [503] Error backend [503] Error backend [503] Error backend [503]

+6
source share
2 answers

Some time ago, perhaps a couple of months later, Google’s download servers started counting down at startup much more than in the past. This is the error you see. There is nothing wrong with the code except for the fact that you are probably just reporting the error and not handling the error.

Most likely you are using the .Upload method. I say this because error 503 returns "The task was canceled." error using .UploadAsync method. I use .UploadAsync and .ResumeAsync in my download program.

When you get this error when using the .Upload method, it indicates that the server is too busy to process your request during the waiting period. Your program should recognize this error and call the .Resume method to resume loading.

Alternatively, you can increase the timeout from 100 seconds by default to something more using this statement: YouTube.HttpClient.Timeout = TimeSpan.FromMinutes(HTTP_CLIENT_TIMEOUT_MINUTES);

where YouTube is the variable name of your YouTubeService object .

In my experience, increasing the timeout is not as effective as processing the error and requesting that the download resume. For example, if you set a timeout of five minutes, your program will still fail if the answer is not returned after five minutes. Yes, it can happen. I usually set a timeout of up to two minutes, and then resume downloading if an error occurs. Almost always, the download will resume correctly.

Sometimes the download may be delayed immediately. For this reason, I count my resumes and reset the resume counter when the ProgressChanged IUploadProgress.Uploading event is fired. I have a limit of three retries and never exceeded that limit.

+1
source

Based on this thread , try to handle this error on your part using some form of exponential rollback or try again.

Example : this method implements an exponential return strategy to resume a failed download.

 def resumable_upload(insert_request): response = None error = None retry = 0 while response is None: try: print "Uploading file..." status, response = insert_request.next_chunk() if 'id' in response: print "Video id '%s' was successfully uploaded." % response['id'] else: exit("The upload failed with an unexpected response: %s" % response) except HttpError, e: if e.resp.status in RETRIABLE_STATUS_CODES: error = "A retriable HTTP error %d occurred:\n%s" % (e.resp.status, e.content) else: raise except RETRIABLE_EXCEPTIONS, e: error = "A retriable error occurred: %s" % e if error is not None: print error retry += 1 if retry > MAX_RETRIES: exit("No longer attempting to retry.") max_sleep = 2 ** retry sleep_seconds = random.random() * max_sleep print "Sleeping %f seconds and then retrying..." % sleep_seconds time.sleep(sleep_seconds) 

You can also upload videos more securely using the renewable upload protocol for the Google APIs . This protocol allows you to resume the download operation after a network interruption or other transmission failure, saving time and bandwidth in the event of a network failure.

Also check out these links:

+1
source

All Articles