- Increase the "ReadTimeout" to 2 hours, as the Worker struggles to get the assignments-data in time.

- Revert the change about special handling of the "RestClientException". The exMsg was appearing in a different line, in the logs, and was a "SocketTimeoutException".
This commit is contained in:
Lampros Smyrnaios 2023-10-27 18:39:10 +03:00
parent bfa76e9484
commit 69ea5b6d19
1 changed files with 3 additions and 13 deletions

View File

@ -55,7 +55,7 @@ public class AssignmentsHandler {
private static final boolean askForTest = false; // Enable this only for testing. private static final boolean askForTest = false; // Enable this only for testing.
private static String requestUrl; private static String requestUrl;
public static final RestTemplate restTemplate = new RestTemplateBuilder().setConnectTimeout(Duration.ofMinutes(2)).setReadTimeout(Duration.ofHours(1)).build(); public static final RestTemplate restTemplate = new RestTemplateBuilder().setConnectTimeout(Duration.ofMinutes(2)).setReadTimeout(Duration.ofHours(2)).build();
public static boolean hadConnectionErrorOnRequest = false; public static boolean hadConnectionErrorOnRequest = false;
@ -108,18 +108,8 @@ public class AssignmentsHandler {
try { // Here, the HTTP-request is executed. try { // Here, the HTTP-request is executed.
assignmentRequest = restTemplate.getForObject(requestUrl, AssignmentsRequest.class); assignmentRequest = restTemplate.getForObject(requestUrl, AssignmentsRequest.class);
} catch (RestClientException rce) { } catch (RestClientException rce) {
final String errorMsg = "Could not retrieve the assignments! "; logger.error("Could not retrieve the assignments! " + rce.getMessage()); // The exMsg also shows the response body of the response (from Spring v.2.5.6 onwards).
String exceptionMsg = rce.getMessage(); // It also shows the response body of the response (from Spring v.2.5.6 onwards). hadConnectionErrorOnRequest = true;
if ( (exceptionMsg != null) && !exceptionMsg.isEmpty() ) {
hadConnectionErrorOnRequest = true;
logger.error(errorMsg + exceptionMsg);
}
else { // Otherwise, it's an undefined error, which occurs randomly
// and does not mean that the Controller has some problem, or the Worker requested something in a wrong way,
// or that the firewall disallow the connection (in this case we get "connection refused/timed out").
logger.error(errorMsg, rce);
// Try again immediately, do not wait 15 mins. The Controller will take some minutes to prepare the data, before it sends them anyway.
}
return null; return null;
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
logger.error("Could not retrieve the assignments, as the provided Controller's url was malformed! " + iae.getMessage()); logger.error("Could not retrieve the assignments, as the provided Controller's url was malformed! " + iae.getMessage());