Keep Alive data packets configuration with Spring Webflux endpoint

I have a use case where a client is invoking a Rest endpoint via a load balancer, which in turn invokes a third party endpoint which is really slow to respond. The third party endpoint takes over 1 min to start sending the response. Because of this the client is getting 504 Gateway timeout due to the connection being idle for more than 60 seconds. We don’t want to alter the configuration of load balancer’s keep alive timeout rather want the Rest endpoint to send some keep alive data packets periodically till the data from third party endpoint is available ensuring that the connection is not idle for long time.

I can implement this by generating a Flux which periodically checks for data availability and returns a dummy packet till the data from third party endpoint is available.
Wanted to know if the same can be achieved just with some out of the box configuration. The goal is to just ensure that the connection does not remain idle till we have data available from the third part endpoint

2 Likes

Corresponding tweet for this thread:

Share link for this tweet.

2 Likes

You could have the rest endpoint send back empty http chunk responses, say, every 30 seconds? It’s not out of the box (as a load balancer generally should be configured to handle the backend correctly) but it’s pretty trivial to do.

1 Like