Question
· Dec 3, 2019

%CSP.REST - java.net.SocketTimeoutException

I am writing an API that sends over a very large JSON object. 

The code I'm using to get the data is actually used in our production system today for the use of writing a report.

However when I call the code using the API (using SoapUI) I am getting 'Error getting response; java.net.SocketTimeoutException: Read timed out'

The web applications settings have a session timeout setting at 15 minutes, but this is timing out within just a few minutes, so I know it's not hitting this mark.

Has anyone experienced this issue with APIs?  We are used to spitting out a lot of data and quickly with Cache so it seems odd that the API would time out in such a way.  I'm not experienced enough with web stuff to know if it's a setting I can control or not however.

Best,

Mike 

Discussion (3)1
Log in or sign up to continue

Check Web Gateway timeouts, specifically Server Response Timeout setting. Also Web Server can impose additional limitations.

That said, I'd advice you to move to async style of API, here's how.

Currently you have one call, say /GetData and it takes 10 minutes.

Split it into 2 calls:

  • /StartTask - JOBs a task (GetData) and returns GUID (child pid in the most simple case)
  • /GetTask/:GUID - returns current JOB status and if it's done returns the data

Here's a sample ASYNC REST broker.

This will save you a lot of problems down the line.

Thank you @Eduard Lebedyuk 

Turns out my problem was 1) bad code and 2) I'm getting a <MAXSTRING> error when building out my JSON object.

Obviously long strings aren't enabled in our instance(s) of Cache . . . and I would probably need to make a really really solid business case to the people who can own and enable that setting.

Can/will moving to an async style of API help this?

{
   "errors": [   {
      "code": 5002,
      "domain": "%ObjectErrors",
      "error": "ERROR #5002: Cache error: <MAXSTRING>zBN0010+91^CLAIMS.mxdavidovich.ApiTestv1.1",
      "id": "CacheError",
      "params": ["<MAXSTRING>zBN0010+91^CLAIMS.mxdavidovich.ApiTestv1.1"]
   }],
   "summary": "ERROR #5002: Cache error: <MAXSTRING>zBN0010+91^CLAIMS.mxdavidovich.ApiTestv1.1"
}