Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
882 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...