java请求返回503,服务器返回的HTTP响应code:503网址

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!

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值