From bf486e374450ca75e0264b776b0b4dec5cb4b925 Mon Sep 17 00:00:00 2001 From: Stefan Sedlmaier Date: Thu, 4 Apr 2024 18:25:34 +0200 Subject: [PATCH] [Senec] Add request timeout (#16611) Fixes #12900. Add a timeout for requests to the local Senec device. Currently there may occur some endlessly hanging requests which basically freeze the values provided by the binding. Signed-off-by: Stefan Sedlmaier --- .../org/openhab/binding/senechome/internal/SenecHomeApi.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.senechome/src/main/java/org/openhab/binding/senechome/internal/SenecHomeApi.java b/bundles/org.openhab.binding.senechome/src/main/java/org/openhab/binding/senechome/internal/SenecHomeApi.java index a85fbc50e4953..9dd66a1dd5647 100644 --- a/bundles/org.openhab.binding.senechome/src/main/java/org/openhab/binding/senechome/internal/SenecHomeApi.java +++ b/bundles/org.openhab.binding.senechome/src/main/java/org/openhab/binding/senechome/internal/SenecHomeApi.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.util.Objects; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -81,7 +82,8 @@ public SenecHomeResponse getStatistics() try { String dataToSend = gson.toJson(new SenecHomeResponse()); logger.trace("data to send: {}", dataToSend); - response = request.method(HttpMethod.POST).content(new StringContentProvider(dataToSend)).send(); + response = request.method(HttpMethod.POST).content(new StringContentProvider(dataToSend)) + .timeout(15, TimeUnit.SECONDS).send(); if (response.getStatus() == HttpStatus.OK_200) { String responseString = response.getContentAsString(); return Objects.requireNonNull(gson.fromJson(responseString, SenecHomeResponse.class));