From 76dd873c2ec877282ae90e0b3887bab3f0dad588 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 5 Oct 2025 15:51:41 +0500 Subject: [PATCH] timeout increase --- .../parser/controller/ReportController.java | 8 ++++- .../parser/service/DeepResearchService.java | 34 +++++++++++-------- src/main/resources/application.properties | 2 +- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/main/java/kz/konturai/parser/controller/ReportController.java b/src/main/java/kz/konturai/parser/controller/ReportController.java index 640d41f..6c2f774 100644 --- a/src/main/java/kz/konturai/parser/controller/ReportController.java +++ b/src/main/java/kz/konturai/parser/controller/ReportController.java @@ -118,7 +118,13 @@ public class ReportController { .doOnError(e -> { System.err.println("Error generating research report async: " + e.getMessage()); }) - .subscribe(); + .subscribe( + ok -> { + }, + err -> { + // Avoid onErrorDropped by consuming error here + System.err.println("Async pipeline error: " + err.getMessage()); + }); ReportGenerationResponse response = new ReportGenerationResponse( taskId, diff --git a/src/main/java/kz/konturai/parser/service/DeepResearchService.java b/src/main/java/kz/konturai/parser/service/DeepResearchService.java index ddf2013..fd2fc25 100644 --- a/src/main/java/kz/konturai/parser/service/DeepResearchService.java +++ b/src/main/java/kz/konturai/parser/service/DeepResearchService.java @@ -25,7 +25,7 @@ public class DeepResearchService { @Value("${deep-research.api.url:http://185.35.223.45:3051}") private String apiUrl; - @Value("${deep-research.api.timeout:300000}") // 5 minutes default timeout + @Value("${deep-research.api.timeout:300000}") // Set to 0 or negative to disable timeout private long timeoutMs; public DeepResearchService() { @@ -40,13 +40,15 @@ public class DeepResearchService { */ public DeepResearchResponse generateReport(DeepResearchRequest request) { try { - return webClient.post() + Mono call = webClient.post() .uri(apiUrl + "/api/research") .bodyValue(request) .retrieve() - .bodyToMono(DeepResearchResponse.class) - .timeout(Duration.ofMillis(timeoutMs)) - .block(); + .bodyToMono(DeepResearchResponse.class); + if (timeoutMs > 0) { + call = call.timeout(Duration.ofMillis(timeoutMs)); + } + return call.block(); } catch (WebClientResponseException e) { throw new RuntimeException("Deep research API error: " + e.getResponseBodyAsString(), e); } catch (Exception e) { @@ -67,15 +69,19 @@ public class DeepResearchService { .bodyToMono(DeepResearchResponse.class) // 👇 Log the successful response object here .doOnSuccess(response -> { - log.info("Deep research API response: {}", response.getLearnings()); - log.info("Deep research API response: {}", response.getMainContent()); - log.info("Deep research API response: {}", response.getError()); - log.info("Deep research API response: {}", response.getStatus()); - log.info("Deep research API response: {}", response.getVisitedUrls()); - }) - .timeout(Duration.ofMillis(timeoutMs)) - .onErrorMap(WebClientResponseException.class, - e -> new RuntimeException("Deep research API error: " + e.getResponseBodyAsString(), e)) + if (response != null) { + log.info("Deep research API response: {}", response.getLearnings()); + log.info("Deep research API response: {}", response.getMainContent()); + log.info("Deep research API response: {}", response.getError()); + log.info("Deep research API response: {}", response.getStatus()); + log.info("Deep research API response: {}", response.getVisitedUrls()); + } + }); + if (timeoutMs > 0) { + temp = temp.timeout(Duration.ofMillis(timeoutMs)); + } + temp = temp.onErrorMap(WebClientResponseException.class, + e -> new RuntimeException("Deep research API error: " + e.getResponseBodyAsString(), e)) .onErrorMap(Exception.class, e -> new RuntimeException("Failed to call deep research API", e)); log.info("*************"); return temp; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 31aa5bf..1d0c9e2 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -62,4 +62,4 @@ spring.mail.properties.mail.smtp.starttls.required=true # Deep Research API Configuration deep-research.api.url=http://185.35.223.45:3051 -deep-research.api.timeout=300000 +deep-research.api.timeout=900000