diff --git a/firebase-installations/src/main/java/com/google/firebase/installations/remote/FirebaseInstallationServiceClient.java b/firebase-installations/src/main/java/com/google/firebase/installations/remote/FirebaseInstallationServiceClient.java index 6dc93ab03ce..51cc1869fae 100644 --- a/firebase-installations/src/main/java/com/google/firebase/installations/remote/FirebaseInstallationServiceClient.java +++ b/firebase-installations/src/main/java/com/google/firebase/installations/remote/FirebaseInstallationServiceClient.java @@ -59,6 +59,8 @@ public class FirebaseInstallationServiceClient { private static final String X_ANDROID_PACKAGE_HEADER_KEY = "X-Android-Package"; private static final String X_ANDROID_CERT_HEADER_KEY = "X-Android-Cert"; + private static final int NETWORK_TIMEOUT_MILLIS = 10000; + private final Context context; public FirebaseInstallationServiceClient(@NonNull Context context) { @@ -90,6 +92,8 @@ public InstallationResponse createFirebaseInstallation( apiKey)); HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection(); + httpsURLConnection.setConnectTimeout(NETWORK_TIMEOUT_MILLIS); + httpsURLConnection.setReadTimeout(NETWORK_TIMEOUT_MILLIS); httpsURLConnection.setDoOutput(true); httpsURLConnection.setRequestMethod("POST"); httpsURLConnection.addRequestProperty(CONTENT_TYPE_HEADER_KEY, JSON_CONTENT_TYPE); @@ -165,6 +169,8 @@ public void deleteFirebaseInstallation( apiKey)); HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection(); + httpsURLConnection.setConnectTimeout(NETWORK_TIMEOUT_MILLIS); + httpsURLConnection.setReadTimeout(NETWORK_TIMEOUT_MILLIS); httpsURLConnection.setDoOutput(true); httpsURLConnection.setRequestMethod("DELETE"); httpsURLConnection.addRequestProperty("Authorization", "FIS_v2 " + refreshToken); @@ -219,6 +225,8 @@ public InstallationTokenResult generateAuthToken( apiKey)); HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection(); + httpsURLConnection.setConnectTimeout(NETWORK_TIMEOUT_MILLIS); + httpsURLConnection.setReadTimeout(NETWORK_TIMEOUT_MILLIS); httpsURLConnection.setDoOutput(true); httpsURLConnection.setRequestMethod("POST"); httpsURLConnection.addRequestProperty("Authorization", "FIS_v2 " + refreshToken);