在远程Ubuntu上部署的springboot项目,其中有一个接口处理时长达到10分钟左右(这个时长是正常的),但是在处理完成时不会return,postman调用时就一直转圈,接收不到回复,于是我测试,把接口内容都不要,仅仅是thread.sleep,等待一些时间后return,发现在5分钟以上都是不return
@PostMapping(value = "/saveLocalByFile1",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseVo saveLocalByFile1 (@RequestParam(value = "file") MultipartFile file){
try {
Thread.sleep(1000*60*5);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("controller");
return ResponseVo.success("","9fz");
}
没报错,就是接收不到return
server.tomcat.max-http-form-post-size=-1
server.tomcat.connection-timeout=2000000
spring.mvc.async.request-timeout=2000000
server.tomcat.maxConnections=2000
server.maxHttpHeaderSize=5000KB
server.tomcat.maxHttpFormPostSize=10240MB
server.tomcat.maxSwallowSize=10240MB
能够接收到返回
未解决,最后改为使用异步修改值判断处理
@ResponseBody
@PostMapping("/bigUploader")
public AjaxResult bigUploader(String chunk,String chunks,String fid,
@RequestParam("file") MultipartFile multipartFile) {
try {
return AjaxResult.success();
} catch (Exception e) {
return AjaxResult.error(AjaxResult.Type.WEBUPLOADERROR.value(),"服务端异常");
}
}
我是这么写的,你用postman发请求的时候,相关的参数设置正确吗?可以贴张图看看。或者debug看下,是不是被其它的方法给拦截了,没有进入这个方法中。
我看你的方法上缺了@ResponseBody,加上这个再试一下。
直接访问的springboot没有nginx啥的么?
亲测使用postman五分钟响应市正常的。
可以在配置文件application.properties中加 spring.mvc.async.request-timeout=600000(10分钟),
可以试一下
看一下springboot,容器(Tomcat?)超时时间设置看看