Microservices Zuul代理服务器在处理请求花费更多时间时引发内部服务器错误
当请求在服务中处理需要更多时间时,我收到此错误。但是Zuul返回内部服务器错误的响应Microservices Zuul代理服务器在处理请求花费更多时间时引发内部服务器错误,microservices,netflix-zuul,proxy-server,Microservices,Netflix Zuul,Proxy Server,当请求在服务中处理需要更多时间时,我收到此错误。但是Zuul返回内部服务器错误的响应 据我所知,使用zuul 2.0.0.RC2版本,在服务没有响应、路由丢失等情况下,您可以设置/error端点以向用户提供自定义响应。 例如: @Controller public class CustomErrorController implements ErrorController { @RequestMapping(value = "/error", produces = "applicati
据我所知,使用zuul 2.0.0.RC2版本,在服务没有响应、路由丢失等情况下,您可以设置/error端点以向用户提供自定义响应。 例如:
@Controller
public class CustomErrorController implements ErrorController {
@RequestMapping(value = "/error", produces = "application/json")
public @ResponseBody
ResponseEntity error(HttpServletRequest request) {
// consider putting these in a try catch
Integer statusCode = (Integer)request.getAttribute("javax.servlet.error.status_code");
Throwable exception = (Throwable)request.getAttribute("javax.servlet.error.exception");
// maybe add some error logging here, e.g. original status code, exception, traceid, etc.
// consider a better error to the user here
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{'message':'some error happened', 'trace_id':'some-trace-id-here'}");
}
@Override
public String getErrorPath() {
return "/error";
}
}