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:
@@ -66,6 +66,7 @@ public class GatewayWebTargets implements Closeable, HostnameVerifier {
|
||||
private static final String IDS = "ids";
|
||||
private static final int SLEEP_SECONDS = 360;
|
||||
private static final Set<Integer> HTTP_OK_CODES = Set.of(HttpStatus.OK_200, HttpStatus.NO_CONTENT_204);
|
||||
private static final int REQUEST_TIMEOUT_MS = 10_000;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(GatewayWebTargets.class);
|
||||
private final Gson jsonParser = new Gson();
|
||||
@@ -248,7 +249,8 @@ public class GatewayWebTargets implements Closeable, HostnameVerifier {
|
||||
logger.trace("invoke() request JSON:{}", jsonCommand);
|
||||
}
|
||||
}
|
||||
Request request = httpClient.newRequest(url).method(method).header("Connection", "close").accept("*/*");
|
||||
Request request = httpClient.newRequest(url).method(method).header("Connection", "close").accept("*/*")
|
||||
.timeout(REQUEST_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
if (query != null) {
|
||||
request.param(query.getKey(), query.getValue());
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
@@ -75,6 +76,7 @@ import com.google.gson.JsonParser;
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class HDPowerViewWebTargets {
|
||||
private static final int REQUEST_TIMEOUT_MS = 30_000;
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(HDPowerViewWebTargets.class);
|
||||
|
||||
@@ -581,7 +583,8 @@ public class HDPowerViewWebTargets {
|
||||
logger.trace("JSON command = {}", jsonCommand);
|
||||
}
|
||||
}
|
||||
Request request = httpClient.newRequest(url).method(method).header("Connection", "close").accept("*/*");
|
||||
Request request = httpClient.newRequest(url).method(method).header("Connection", "close").accept("*/*")
|
||||
.timeout(REQUEST_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
if (query != null) {
|
||||
request.param(query.getKey(), query.getValue());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user