Google App Engine + Cloud Endpoints + Google Translate API = 502 Bad Gateway
问题描述:
我已经使用云端点创建了一个简单的API,它使用Google Translate API进行了一些翻译,将它们缓存在数据存储中,并将结果列表返回给客户端。 问题是,我每次打电话时,都会使用Google Translate API,我收到502错误的网关错误。 我一直在从云端控制台调试我的端点,并且响应已成功创建,所以在将结果发送回客户端时必须引发502。另一个奇怪的问题是,我没有在云控制台的任何日志工具上看到502。Google App Engine + Cloud Endpoints + Google Translate API = 502 Bad Gateway
我试图改变从欧洲西部到美国中部地区,但目前还没有运气。 有没有人有任何想法,这里可能是错误的?
我的GAE的cofnig:
runtime: java7
env: standard
threadsafe: true
instance_class: B2
inbound_services:
- warmup
handlers:
- url: '(/.*/)'
application_readable: false
static_files: "__static__\\1index.html"
require_matching_file: true
upload: __NOT_USED__
- url: (/)
application_readable: false
static_files: "__static__\\1index.html"
require_matching_file: true
upload: __NOT_USED__
- url: '(/.*)'
application_readable: false
static_files: "__static__\\1"
require_matching_file: true
upload: __NOT_USED__
- url:/
script: unused
- url: '/.*/'
script: unused
- url: '/_ah/.*'
script: unused
basic_scaling:
idle_timeout: 900s
max_instances: 2
当改变GAE的配置和除去基本缩放我从谷歌得到翻译以下错误:
com.google.cloud.translate.TranslateException: com.google.apphosting.api.ApiProxy$CancelledException: The API call urlfetch.Fetch() was cancelled because the overall HTTP request deadline was reached.
at io.stringx.repository.DatastoreTranslationRepository.translate (DatastoreTranslationRepository.java:53)
答
原来,谷歌云端点有60截止日期限制,所以我不得不在大块中提出我的请求: https://cloud.google.com/appengine/articles/deadlineexceedederrors#UrlFetch_Delays