mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[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 <github@ssedlmaier.de>
This commit is contained in:
parent
7f4686926b
commit
bf486e3744
@ -15,6 +15,7 @@ package org.openhab.binding.senechome.internal;
|
||||
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 class SenecHomeApi {
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user