Skip to content

Commit bf486e3

Browse files
authored
[Senec] Add request timeout (openhab#16611)
Fixes openhab#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 <[email protected]>
1 parent 7f46869 commit bf486e3

File tree

1 file changed

+3
-1
lines changed
  • bundles/org.openhab.binding.senechome/src/main/java/org/openhab/binding/senechome/internal

1 file changed

+3
-1
lines changed

bundles/org.openhab.binding.senechome/src/main/java/org/openhab/binding/senechome/internal/SenecHomeApi.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.io.IOException;
1616
import java.util.Objects;
1717
import java.util.concurrent.ExecutionException;
18+
import java.util.concurrent.TimeUnit;
1819
import java.util.concurrent.TimeoutException;
1920

2021
import org.eclipse.jdt.annotation.NonNullByDefault;
@@ -81,7 +82,8 @@ public SenecHomeResponse getStatistics()
8182
try {
8283
String dataToSend = gson.toJson(new SenecHomeResponse());
8384
logger.trace("data to send: {}", dataToSend);
84-
response = request.method(HttpMethod.POST).content(new StringContentProvider(dataToSend)).send();
85+
response = request.method(HttpMethod.POST).content(new StringContentProvider(dataToSend))
86+
.timeout(15, TimeUnit.SECONDS).send();
8587
if (response.getStatus() == HttpStatus.OK_200) {
8688
String responseString = response.getContentAsString();
8789
return Objects.requireNonNull(gson.fromJson(responseString, SenecHomeResponse.class));

0 commit comments

Comments
 (0)