RE: What would cause a timeout to an external API at exactly 120 seconds

thumbnail
Pete Helgren, modified 3 Years ago. Regular Member Posts: 225 Join Date: 4/7/11 Recent Posts

I have a portlet that makes a call to a long running API.  What is interesting is that I have a development environment that does not time out yet the production environment will time out (actually with an HTTP 502 error) at exactly 120 seconds.  I don't belive that there is any issue at the remote since it will successfully run in development.  Both the production and development environment use the same outbound routing and gateway.

The only notable difference is that the production environment is Linux (CENTOS) and the development environment is Windows 10.  Otherwise the Liferay version is the same: 7.3.2-ga3 and the module deplyed is the same.  I checked the server.xml, context.xml, portal-ext.properties and they are the same.  I suspect that I made a change to a variable *somewhere* but I cannot find any difference in either environment that would point to a change.

FWIW the API is accessed via a REST call using HttpsURLConnection.

Can you think of a setting in Liferay that might affect a timeout for an external API call?  I haven't been able to find anything.
 

thumbnail
Gennaro Lippiello, modified 3 Years ago. Junior Member Posts: 39 Join Date: 3/9/22 Recent Posts
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
con.setConnectTimeout(your_time);

Just set the timeout to "your_time" milliseconds

thumbnail
Pete Helgren, modified 3 Years ago. Regular Member Posts: 225 Join Date: 4/7/11 Recent Posts

Thanks Gennaro.  I have seen that suggestion in other forums.  What I don't understand is why it would work, without setting that value, in a development environment but would be needed in production..  I would understand that change if it timed out at 120 seconds in both the development and production environments since the same module/portlet would be deployed in both.

​​​​​​​But, perhaps it will override any other setting so I'll give it a try.  Thanks for the suggestion.

​​​​​​​Pete

thumbnail
Gennaro Lippiello, modified 3 Years ago. Junior Member Posts: 39 Join Date: 3/9/22 Recent Posts

Take a look also to the method setReadTimeout 

thumbnail
Pete Helgren, modified 3 Years ago. Regular Member Posts: 225 Join Date: 4/7/11 Recent Posts

Again, thanks.

More digging... turns out the one difference between the development and production system is that the production instance is front-ended by Apache and the Apache instance is a reverse proxy with a value of "ProxyPass / http://XXX.XXX.XXX.XXX:7080/ timeout=120 retry=0"  Exactly two minutes.

So, it was a configuration setting...but in Apache HTTP rather than Liferay.

Thanks for all the suggestions.