Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
904 views
in Technique[技术] by (71.8m points)

java - Timeout on blocking read for 5000 MILLISECONDS in Spring WEBLUX

i wrote a test for Handler (spring weblux)

test:

@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

the handler is simple

 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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();
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...