Vert.x response has already been written

 

Vert.x response has already been written

https://stackoverflow.com/questions/59935129/vert-x-response-has-already-been-written

 

I am facing a problem with vert.x. When the timeout is triggered it generates a response, then the actual response (takes 10 sec) comes and tries to do the response, so I get a:

java.lang.IllegalStateException: Response has already been written

I am new with Vert.x and I am not sure about the desired behaviour, How should I do it?, since the code is asynchronous I don't find the way to check whether the response has been already sent.

Is there any way to do it porperly?

 

3
 

I found out this method, apparently it works:

if (!req.response().ended()) {
    req.response().end(response.body());
}
posted @ 2023-03-10 10:19  2一念轮回2  阅读(111)  评论(0)    收藏  举报