YouTube的V3 API - Google.Apis.Requests.RequestErrorBackend错误[503]
我已经上传到YouTube的视频与我的软件一段时间,一切都已经一年多了,现在工作的罚款。我认为东西在后台发生了变化,谷歌告诉我使用标签和我的问题在这里发布,所以在这儿呢。
I have been uploading videos to YouTube for a while with my software, and everything has been working fine for over a year now. I assume something has changed in the 'backend', and Google tells me to post here with my problems using the tag, so here it is.
这发生在我上传一段录像。该视频上传到99%,那么这个错误被抛出。 ResumeAsync()似乎不断抛出此错误。
This happens when I upload a video. The video uploads to 99%, then this error is thrown. ResumeAsync() seems to constantly throw this error.
C#侧面说明:我不知道这是否适用于其他编程语言真实,但与C#API,以便使用ResumeAsync(),您需要设置ResumableUpload对象的两个私有属性:UploadUri和StreamLength
C# Side Note: I'm not sure if this holds true for other programming languages, but with the C# API, in order to use ResumeAsync(), you need to set two PRIVATE properties of the ResumableUpload object: UploadUri and StreamLength.
我利用UploadAsync和ResumeAsync方法与按照谷歌的准则执行一个指数退避策略。
I utilize the UploadAsync and ResumeAsync methods with an 'exponential backoff strategy' implemented as per Google guidelines.
我曾尝试创建一个新的开发客户端ID,服务器ID和所有这一切,同样的结果。我也试图上传到一个不同的YouTube,相同的结果。这不是一个配额问题。我的配额是5%,除此之外,我创建了一个新的谷歌开发者的应用程序。
I have tried creating a new developer Client ID, server ID and all that, same result. I have also tried uploading to a different YouTube, same result. It's not a quota issue. My quota is at 5%, besides, I created a new Google developer app.
Google.Apis.YouTube.v3
运行时间:v4.0.30319
版本:1.12.0.461
Google.Apis.YouTube.v3 Runtime: v4.0.30319 Version: 1.12.0.461
错误
Google.Apis.Requests.RequestError
Error Google.Apis.Requests.RequestError
后端错误[503]
Errors [
Message[Backend Error] Location[ - ] Reason[backendError] Domain[global]
]
在System.Net.HttpStatusCode.Gone Google.Apis.Upload.ResumableUpload`1.d__91.MoveNext()在C:\Users\mdril\Documents\GitHub\google-API -dotnet-client\Src\GoogleApis\Apis [媒体] \Upload\ResumableUpload.cs:553
System.Net.HttpStatusCode.Gone at Google.Apis.Upload.ResumableUpload`1.d__91.MoveNext() in C:\Users\mdril\Documents\GitHub\google-api-dotnet-client\Src\GoogleApis\Apis[Media]\Upload\ResumableUpload.cs:line 553
修改
不久后,这些错误的出现,YouTube的电子邮件发送以下内容:
的 https://developers.google.com/youtube/terms/required-minimum-functionality
我猜他们是为即将开幕的要求做准备。我认为他们很快会写我们应用我们!哈哈!过多的控制权!
I guess they are preparing for these upcoming requirements. I think soon they are going to write our applications for us! haha! Too much control!
此的线程,试图在最终处理这个错误有某种形式的
的指数回退或重试。
Based from this thread, try to handle this error at your end with some form of exponential back-off or retry.
示例:此方法实现了指数退避策略,以恢复失败的上传
Example: This method implements an exponential backoff strategy to resume a failed upload.
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)
您也可以使用继续上传协议谷歌API的。此协议可以恢复上载操作网络中断或其他传输失败后,节省了时间和带宽,在网络出现故障的情况下
You can also upload videos more reliably by using the resumable upload protocol for Google APIs. This protocol lets you resume an upload operation after a network interruption or other transmission failure, saving time and bandwidth in the event of network failures.
也检查这些链接:
- Youtube api v3 throws an exception during upload
- https://code.google.com/p/gdata-issues/issues/detail?id=4020