Skip to content

Commit

Permalink
Use less stringent timeouts in REST client
Browse files Browse the repository at this point in the history
  • Loading branch information
GenieTim committed Dec 27, 2023
1 parent acea008 commit 477b3af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public ArrayList<JSONObject> uploadImagesForSpecimen(Specimen specimen) throws I
MultipartBodyPublisher multipartBody = MultipartBodyPublisher.newBuilder().filePart("image", Path.of(imagePath), MediaType.IMAGE_ANY).build();
log.debug("Built multipart body...");
MutableRequest request = MutableRequest.POST(queryUrl, multipartBody).header("Content-Disposition", "attachment; filename=\"" + image.getFilename() + "\"");
log.debug("Built request to uplaod...");
log.debug("Built request to upload...");
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());

log.debug("Response from uploading image: " + response.body());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public abstract class AbstractRestClient {
public AbstractRestClient() {
Methanol.Builder builder = Methanol.newBuilder()
.userAgent("DataShot " + ImageCaptureApp.getAppVersion())
.requestTimeout(Duration.ofSeconds(60)) // Default request timeout
.headersTimeout(Duration.ofSeconds(30)) // Timeout for receiving response headers
.readTimeout(Duration.ofSeconds(30)); // Timeout for single reads;
httpClient = builder.executor(Executors.newFixedThreadPool(4))
.connectTimeout(Duration.ofSeconds(60))
.requestTimeout(Duration.ofSeconds(360)) // Default request timeout
.headersTimeout(Duration.ofSeconds(120)) // Timeout for receiving response headers
.readTimeout(Duration.ofSeconds(60)); // Timeout for single reads;
httpClient = builder.executor(Executors.newFixedThreadPool(8))
.connectTimeout(Duration.ofSeconds(120))
.build();
}

Expand Down

0 comments on commit 477b3af

Please sign in to comment.