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

@@ -82,6 +82,7 @@ import com.google.gson.stream.JsonWriter;
public class SensiboAccountHandler extends BaseBridgeHandler {
private static final int MIN_TIME_BETWEEEN_MODEL_UPDATES_MS = 30_000;
private static final int SECONDS_IN_MINUTE = 60;
private static final int REQUEST_TIMEOUT_MS = 10_000;
public static String API_ENDPOINT = "https://home.sensibo.com/api";
private final Logger logger = LoggerFactory.getLogger(SensiboAccountHandler.class);
private final HttpClient httpClient;
@@ -275,6 +276,7 @@ public class SensiboAccountHandler extends BaseBridgeHandler {
private Request buildRequest(final AbstractRequest req) {
Request request = httpClient.newRequest(API_ENDPOINT + req.getRequestUrl()).param("apiKey", config.apiKey)
.method(req.getMethod());
request.timeout(REQUEST_TIMEOUT_MS, TimeUnit.MILLISECONDS);
if (!req.getMethod().contentEquals(HttpMethod.GET.asString())) { // POST, PATCH
final String reqJson = gson.toJson(req);