服务器返回的HTTP响应code:503网址 [英] Server returned HTTP response code: 503 for URL

查看:7136
本文介绍了服务器返回的HTTP响应code:503网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获得 异常线程mainjava.io.IOException异常:服务器返回的HTTP响应code:503网址错误,当我多次调用亚马逊产品广告API。

是服务的重载的原因是什么?
一个可能的解决方法是使用了Thread.Sleep(毫秒)方法。

但还有没有其他更复杂的解决方案?就像代理什么的?

下面是用于建立连接的code:

  URL =亚马逊新的URL(网址);
        URLConnection的YC = amazon.openConnection();
        在的BufferedReader =新的BufferedReader(
                                新的InputStreamReader(
                                yc.getInputStream()));

我使用Java!


解决方案

HTTP ://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html ,它定义了这些状态codeS:


10.5.4 503服务不可用

服务器目前无法处理请求由于服务器暂时超载或维护。的含意是,这是将一些延迟之后被减轻的临时状态。如果知道的话,延迟的长度可以在Retry-After头指示。如果没有给出重试后,客户端应该处理的响应,因为它会为一个500响应。
注:503状态code的存在并不意味着一个服务器必须使用它超载的时候。有些服务器不妨干脆拒绝连接。

所以,是的,服务器超载是一个可能的原因。为了弄清楚如何处理这个你可能要与谁操作服务,以讨论,了解他们可以容忍的。然后,如果你搜索油门Web请求上的话,你会发现一些如何实现节流,一旦你知道你的要求的讨论。

修改

现在,我看到你在谈论亚马逊的广告API,快速搜索让我到这个网页:的http://docs.aws.amazon.com/AWSECommerceService/latest/DG/TroubleshootingApplications.html

效益指引在该页面pretty明确规定将触发你的问题,那是可以接受的请求率。

Getting "Exception in thread "main" java.io.IOException: Server returned HTTP response code: 503 for URL" error when I make multiple calls to Amazon Product Advertising API.

Is the reason overloading of the service? One Possible solution is to use Thread.Sleep(milliseconds) method.

But is there any other more sophisticated solution? Like proxies or something?

Here is the code used to make the connection:

URL amazon = new URL(url);
        URLConnection yc = amazon.openConnection();
        BufferedReader in = new BufferedReader(
                                new InputStreamReader(
                                yc.getInputStream()));

I am using Java!

解决方案

From http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html, which defines these status codes:

10.5.4 503 Service Unavailable

The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.

Note: The existence of the 503 status code does not imply that a server must use it when becoming overloaded. Some servers may wish to simply refuse the connection.

So yes, server overload is a likely cause. To figure out how to deal with this you probably want to discuss it with whoever operates the service, to understand what they can tolerate. Then, if you search for "throttle web requests" on SO, you'll find a number of discussions of how to implement throttling once you know your requirement.

Edit

Now that I see you're talking about Amazon Advertising API, a quick search got me to this page: http://docs.aws.amazon.com/AWSECommerceService/latest/DG/TroubleshootingApplications.html

The Efficiency Guidelines on that page pretty clearly state what will trigger your problem, and the request rates that are acceptable.

这篇关于服务器返回的HTTP响应code:503网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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