HTTP 503用于一些REST API调用
我正在运行一个Springboot应用程序,并且有一个控制器来定义REST API并接受ID列表的请求。通常,它可以正常工作,但是如果ID数量变大,那么我会收到HTTP 503。有趣的是,我看不到控制器也收到我的请求的任何日志。因此,我无法理解正在发生的事情。您知道什么值得检查吗?
I am running an SpringBoot application and I have a controller which defines Rest Api and accepts a request by a list of ids. Normally it works fine but if number of ids gets bigger, then I receive http 503. Interesting thing is that I cannot see any logs that my request was received by controller as well. Therefore I am not able to understand what is happening. Do you have any idea what can be worth to check ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
503是一个错误代码,这意味着您的要求,您的要求是不运行/可用,请确保您的JAR文件正在运行,并确保您请求的URL有效。由于无法使用服务,因此您无法看到任何日志或错误消息。因为您的控制器DINT会收到任何请求。
503 is a error code, which means service or url or controller, that you are requested is not running/available, make sure your jar file is running and also make sure the url you requested is valid. since service is not available you cant see any logs or error messages. because your controller dint receive any request yet.
503错误表明服务器尚未准备好处理请求。
通过URL传输数据存在一些局限性,基本上是URL的长度
通常,极限是2047个字符,不同的浏览器也有所不同
The 503 error indicate that the server is not ready to handle the request.
There are some limitations for transferring data through URL , basically the length of the URL
In general the limit was 2047 chars and it is different for different browsers
503表示不可用的服务。
我认为您的要求有问题。
您可以尝试添加一次自定义的PerrequestFilter并记录您的HTTP请求。
503 means Service Unavailable.
I think something is wrong with your request.
You can try to add a custom OncePerRequestFilter and log your HTTP Request.
就我而言,问题是由 async请求超时引起的。
执行30秒后,它正好返回503,因为它是默认的tomcats的异步请求超时,请参阅此处: https://tomcat.apache.org/tomcat-9.0-doc/config/chconfig/http.html
street street
spring.mvc.m.mvc.async.request tere 超过
30 000
MS为我解决了问题。有关一些详细信息,请参见以下问题: Spring Boot Rest Rest API-请求超时?
In my case the problem was caused by async request timeout.
It was returning 503 exactly after 30 seconds of execution because it's the default Tomcats' timeout for asynchronous requests, see e.g. here: https://tomcat.apache.org/tomcat-9.0-doc/config/http.html
Setting
spring.mvc.async.request-timeout
to more than30 000
ms fixed the problem for me.See e.g. following question for some details: Spring Boot REST API - request timeout?