【问题标题】:Receiving Response Code 502 from Google Custom Search JSON API从 Google 自定义搜索 JSON API 接收响应代码 502
【发布时间】:2019-10-08 19:32:55
【问题描述】:

我正在向此处的文档中指定的 Google 自定义搜索发出 HTTP 请求 https://developers.google.com/custom-search/v1/cse/list

几天前一切正常,但是,现在搜索 API 偶尔返回 502 ERROR。大多数搜索请求都会通过,但有些会返回通用的“这是一个错误”页面

还有其他人得到这个吗?

有人知道 Google 自定义搜索 JSON 服务是否有状态页面吗?

这是来自 JSON API 的响应正文

<!DOCTYPE html>
<html lang=en>
 <meta charset=utf-8>
 <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
 <title>Error 502 (Server Error)!!1</title>
 <style>
   {margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px} > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
 </style>
 <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
 <p><b>502.</b> <ins>That’s an error.</ins>
 <p>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.  <ins>That’s all we know.</ins>

【问题讨论】:

  • 我们也收到了很多。想知道 Google 到底发生了什么。

标签: google-custom-search


【解决方案1】:

在过去的几天里,我们在使用 .NET 客户端时遇到了完全相同的问题,而且这似乎肯定是在 Google 这边。 我通过添加重试机制“解决了”这个问题。当 listRequest.Execute().Items 失败时,我捕获异常,休眠一秒钟并重试。到目前为止是唯一有效的方法。

【讨论】:

  • 这不是一个坏主意。但似乎这可能已经得到解决,在过去 10 小时内没有收到此错误。
  • @lev 感谢您告诉我。我会检查是否发生这种情况,但请保留重试代码以防万一。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多