Skip to content

Commit 2485058

Browse files
authored
feat(predictions): Added region handling for creating correct streaming endpoint from region (#2923)
1 parent aa6e1ff commit 2485058

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

aws-predictions/src/main/java/com/amplifyframework/predictions/aws/service/RunFaceLivenessSession.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ internal class RunFaceLivenessSession(
4747
onError: Consumer<PredictionsException>
4848
) {
4949

50-
private val livenessEndpoint = "wss://streaming-rekognition.${sessionInformation.region}.amazonaws.com:443"
50+
private val livenessEndpoint = getStreamingEndpointForRegion(sessionInformation.region)
5151

5252
private val livenessWebSocket = LivenessWebSocket(
5353
credentialsProvider = credentialsProvider,
@@ -183,4 +183,17 @@ internal class RunFaceLivenessSession(
183183
livenessWebSocket.clientStoppedSession = true
184184
reasonCode?.let { livenessWebSocket.destroy(it) } ?: livenessWebSocket.destroy()
185185
}
186+
187+
private fun getStreamingEndpointForRegion(region: String): String {
188+
val baseDomain = when {
189+
region.startsWith("us-isof", ignoreCase = true) -> ISO_PARTITION_BASE_DOMAIN
190+
else -> DEFAULT_BASE_DOMAIN
191+
}
192+
return "wss://streaming-rekognition.$region.$baseDomain:443"
193+
}
194+
195+
companion object {
196+
private const val ISO_PARTITION_BASE_DOMAIN = "csp.hci.ic.gov"
197+
private const val DEFAULT_BASE_DOMAIN = "amazonaws.com"
198+
}
186199
}

0 commit comments

Comments
 (0)