Google Places API错误502-服务器遇到临时错误 [英] Google Places API error 502 - The server encountered a temporary error

查看:99
本文介绍了Google Places API错误502-服务器遇到临时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们经营一个网站,该网站通过Google Place API获取位置数据.我们每天有15万次搜索,但由于该网站仅启用了几个星期,因此我们尚未遇到.我们突然收到502错误.控制台中的通知显示:服务器遇到临时错误,无法完成您的请求."这是暂时的错误吗?关于我们的工作有什么建议吗?该网站已关闭40分钟.

we run a website that obtains location data through the Google Place API. We have 150k daily searches available, which we haven´t met yet as the website has been live for few weeks only. We have suddenly received a 502 error. A notification in the Console says: "The server encountered a temporary error and could not complete your request.". Is this a temporary error? Is there any suggestions on what we can do? The website hasn’t been available for 40 minutes.

推荐答案

当您在响应中收到5xx状态或UNKNOWN_ERROR时,应实现重试逻辑.Google在其网络服务文档中有以下建议:

When you receive 5xx status or UNKNOWN_ERROR in the response, you should implement a retrying logic. Google has a following recommendation in their web services documentation:

在极少数情况下,满足您的请求可能会出错;您可能会收到4XX或5XX HTTP响应代码,或者客户端和Google服务器之间的TCP连接可能会失败.通常,重新尝试该请求是值得的,因为当原始请求失败时,后续请求可能会成功.但是,重要的是不要简单地循环反复向Google服务器发出请求.这种循环行为可能会使您的客户和Google之间的网络过载,从而给许多方面带来麻烦.

In rare cases something may go wrong serving your request; you may receive a 4XX or 5XX HTTP response code, or the TCP connection may simply fail somewhere between your client and Google's server. Often it is worthwhile re-trying the request as the followup request may succeed when the original failed. However, it is important not to simply loop repeatedly making requests to Google's servers. This looping behavior can overload the network between your client and Google causing problems for many parties.

一种更好的方法是尝试之间的延迟增加而重试.通常,每次尝试都会使延迟增加一个倍增因子,这种方法称为指数退避.

A better approach is to retry with increasing delays between attempts. Usually the delay is increased by a multiplicative factor with each attempt, an approach known as Exponential Backoff.

https://developers.google.com/maps/documentation/directions/web-service-best-practices#exponential-backoff

但是,如果使用指数补偿的重试逻辑无济于事,并且该错误持续了很长时间,您应该在

However, if retrying logic with Exponential Backoff doesn't help and the error persists for a long time you should file a bug in Google issue tracker

我希望这能解决您的疑问!

I hope this addresses your doubt!

更新

昨天(2017年11月6日),Google方面出现问题,您可以参考以下错误来解释该问题:

There was an issue on Google side yesterday (November 6, 2017), you can refer to the following bug that explains the issue:

https://issuetracker.google.com/issues/68938173

这篇关于Google Places API错误502-服务器遇到临时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆