diff --git a/bundles/org.openhab.binding.surepetcare/src/main/java/org/openhab/binding/surepetcare/internal/SurePetcareAPIHelper.java b/bundles/org.openhab.binding.surepetcare/src/main/java/org/openhab/binding/surepetcare/internal/SurePetcareAPIHelper.java index e9a1747384e30..305dbcf04763c 100644 --- a/bundles/org.openhab.binding.surepetcare/src/main/java/org/openhab/binding/surepetcare/internal/SurePetcareAPIHelper.java +++ b/bundles/org.openhab.binding.surepetcare/src/main/java/org/openhab/binding/surepetcare/internal/SurePetcareAPIHelper.java @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Enumeration; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -108,7 +109,7 @@ public synchronized void login(String username, String password) throws Authenti setConnectionHeaders(request); request.content(new StringContentProvider(SurePetcareConstants.GSON .toJson(new SurePetcareLoginCredentials(username, password, getDeviceId().toString())))); - ContentResponse response = request.send(); + ContentResponse response = request.timeout(SurePetcareConstants.DEFAULT_HTTP_TIMEOUT, TimeUnit.SECONDS).send(); if (response.getStatus() == HttpURLConnection.HTTP_OK) { SurePetcareLoginResponse loginResponse = SurePetcareConstants.GSON .fromJson(response.getContentAsString(), SurePetcareLoginResponse.class); @@ -450,7 +451,7 @@ private ContentResponse executeAPICall(Request request) throws SurePetcareApiExc while (retries > 0) { try { setConnectionHeaders(request); - ContentResponse response = request.send(); + ContentResponse response = request.timeout(SurePetcareConstants.DEFAULT_HTTP_TIMEOUT, TimeUnit.SECONDS).send(); if ((response.getStatus() == HttpURLConnection.HTTP_OK) || (response.getStatus() == HttpURLConnection.HTTP_CREATED)) { return response; diff --git a/bundles/org.openhab.binding.surepetcare/src/main/java/org/openhab/binding/surepetcare/internal/SurePetcareConstants.java b/bundles/org.openhab.binding.surepetcare/src/main/java/org/openhab/binding/surepetcare/internal/SurePetcareConstants.java index 1ffab13d3cc8d..13a474203364e 100644 --- a/bundles/org.openhab.binding.surepetcare/src/main/java/org/openhab/binding/surepetcare/internal/SurePetcareConstants.java +++ b/bundles/org.openhab.binding.surepetcare/src/main/java/org/openhab/binding/surepetcare/internal/SurePetcareConstants.java @@ -54,6 +54,7 @@ public class SurePetcareConstants { public static final long DEFAULT_REFRESH_INTERVAL_TOPOLOGY = 36000; // 10 hours public static final long DEFAULT_REFRESH_INTERVAL_STATUS = 300; // 5 mins + public static final int DEFAULT_HTTP_TIMEOUT = 8; public static final String PROPERTY_NAME_ID = "id";