Set explicit timeout for http request (#15505)

* Bondhome
* chatgpt
* electroluxair
* energidataservice
* freeboxos
* gardena
* generacmobilelink
* hdpowerview
* icalendar
* juicenet
* kostalinverter
* liquidcheck
* mcd
* meater
* miele
* mercedesme
* mybmw
* myq
* ojelectronics
* plex
* radiothermostat
* renault
* semsportal
* sensibo
* tapocontrol
* tellstick
* verisure
* vizio

---------

Signed-off-by: lsiepel <leosiepel@gmail.com>
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel
2023-10-19 22:30:41 +02:00
committed by GitHub
parent c7568cb206
commit 7313415ae0
32 changed files with 135 additions and 48 deletions

View File

@@ -15,6 +15,7 @@ package org.openhab.binding.tellstick.internal.local;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.jetty.client.HttpClient;
@@ -69,6 +70,7 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
static final String HTTP_LOCAL_API_DEVICE_TURNOFF = HTTP_LOCAL_API + "device/turnOff?id=%d";
static final String HTTP_LOCAL_DEVICE_TURNON = HTTP_LOCAL_API + "device/turnOn?id=%d";
private static final int MAX_RETRIES = 3;
private static final int REQUEST_TIMEOUT_MS = 10_000;
public TelldusLocalDeviceController(TelldusLocalConfiguration configuration, HttpClient httpClient) {
this.httpClient = httpClient;
@@ -270,7 +272,8 @@ public class TelldusLocalDeviceController implements DeviceChangeListener, Senso
throws ExecutionException, InterruptedException, TimeoutException, JsonSyntaxException {
logger.trace("HTTP GET: {}", uri);
Request request = httpClient.newRequest(uri).method(HttpMethod.GET);
Request request = httpClient.newRequest(uri).method(HttpMethod.GET).timeout(REQUEST_TIMEOUT_MS,
TimeUnit.MILLISECONDS);
request.header("Authorization", authorizationHeader);
ContentResponse response = request.send();