Razink
Razink

Reputation: 35

Http Inbound Gateway takes 2x timeout to send timeout response to client

We're using an http inbound gateway to process http requests. Lately , we wanted to set specific http response code that will be sent to user after a timeout. We upgraded to spring 4.2.1 and set

the reply-timeout-status-code-expression attribute

and it's working now.

But there is a problem : if we set the timeout to 10 seconds , a ReplyTimeoutException is raised in the web application after exactly 10 seconds but the response arrives to the client after 20 seconds ( exactly the double ).

We changed the timeout several times but it always take 2x timeout for the response to be received by client.

This is the xml config for the http inbound gateway :

<int-http:inbound-gateway id="inboundRequest" request-channel="inbound-channel" 
         supported-methods="POST" path="/Request" error-channel="errorChannel" reply-channel="gateway_response"
        reply-timeout="5000" request-payload-type="java.lang.String" reply-timeout-status-code-expression="'504'" >

A Help would be really appreciated

Upvotes: 0

Views: 311

Answers (1)

Gary Russell
Gary Russell

Reputation: 174769

I see you have an error-channel - if the error flow returns no response, the reply timer starts again when the error flow ends (we're waiting for a reply from the error flow).

Instead of returning nothing from the error flow, you need to throw a MessageTimeoutException.

Turning on DEBUG logging and following the message flow is the best way to diagnose issues like this.

If that's not the problem, you need to show the rest of your configuration (edit the question, don't try to post it in a comment).

Upvotes: 1

Related Questions