春季WEBLUX中阻止读取5000 MILLISECONDS的超时 [英] Timeout on blocking read for 5000 MILLISECONDS in Spring WEBLUX

查看:42
本文介绍了春季WEBLUX中阻止读取5000 MILLISECONDS的超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Handler(spring weblux)编写了一个测试

i wrote a test for Handler (spring weblux)

测试:

@Test
    public void checkServicesHandlerTest(){
      Request request = new Request();
        request.setMsisdn("ffdfdfd");

        this.testClient.post().uri("/check")
                .body(Mono.just(request), Request.class).exchange().expectStatus().isOk();       
    }

但是结果我有一个错误.

But in result i have an error.

Timeout on blocking read for 5000 MILLISECONDS

处理程序很简单

 public Mono<ServerResponse> check(ServerRequest request){

       Request request = request.bodyToMono(Request.class).block();

问题出在哪里?但是如果我直接向服务器发送请求,一切正常.

Where is the problem ? but if i send a direct request to server all is ok.

推荐答案

运行集成测试时,我看到了类似的问题和异常,其中一些测试汇总了来自其他具有数据库访问权限和其他内容的服务的响应.因此,在运行集成测试时,我们间歇性地看到此问题.我们正在将Spring Boot 2.0.0.RC1和Junit 5与Gradle一起使用.我这样做是为了解决问题.关键是使网络客户端发生变异,最坏的情况下响应超时为30秒.

I was seeing similar issue and Exception when running Integration tests some of them aggregates responses from multiple other services which has database access and stuff. So we were seeing this issue intermittently when running Integration tests. We are using Spring Boot 2.0.0.RC1 and Junit 5 with Gradle. I did this to resolve the issue. The key is mutating the webclient with a response timeout of 30 seconds the worst case.

    @Autowired
    private WebTestClient webTestClient;

        @BeforeEach
        public void setUp() {
         webTestClient = webTestClient
                            .mutate()
                            .responseTimeout(Duration.ofMillis(30000))
                            .build();
        }

这篇关于春季WEBLUX中阻止读取5000 MILLISECONDS的超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆