使用Spring Webflux在我的反应性REST端点上工作时,我意识到,如果返回的Publisher
在约30秒内未完成,则会被取消并返回响应代码503。
我没有在任何地方看到这种行为的记录。
示例REST控制器:
package myapp.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import javax.servlet.http.HttpServletRequest;
import java.time.Duration;
@RestController
public class TestAlationIndexingRestController {
@RequestMapping(
value = "/test",
method = RequestMethod.GET
)
public Mono<String> test(HttpServletRequest request) {
return Mono.delay(Duration.ofMinutes(2)).thenReturn("Late");
}
}
回复:503,没有回复内容
我的问题:如何禁用此行为,或者至少增加超时时间?
注意:我尝试使用应用程序属性server.connection-timeout: -1
或server.connection-timeout: 15
失败-请求超过30秒后仍然超时。
我正在使用Spring Boot依赖项(版本2.1.6-RELEASE
):
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-reactor-netty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
和
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.2.12.RELEASE</version>
</dependency>