diff --git a/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/service/RunFaceLivenessSession.kt b/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/service/RunFaceLivenessSession.kt index d6d1000fd..0481720ee 100644 --- a/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/service/RunFaceLivenessSession.kt +++ b/aws-predictions/src/main/java/com/amplifyframework/predictions/aws/service/RunFaceLivenessSession.kt @@ -47,7 +47,7 @@ internal class RunFaceLivenessSession( onError: Consumer ) { - private val livenessEndpoint = "wss://streaming-rekognition.${sessionInformation.region}.amazonaws.com:443" + private val livenessEndpoint = getStreamingEndpointForRegion(sessionInformation.region) private val livenessWebSocket = LivenessWebSocket( credentialsProvider = credentialsProvider, @@ -183,4 +183,17 @@ internal class RunFaceLivenessSession( livenessWebSocket.clientStoppedSession = true reasonCode?.let { livenessWebSocket.destroy(it) } ?: livenessWebSocket.destroy() } + + private fun getStreamingEndpointForRegion(region: String): String { + val baseDomain = when { + region.startsWith("us-isof", ignoreCase = true) -> ISO_PARTITION_BASE_DOMAIN + else -> DEFAULT_BASE_DOMAIN + } + return "wss://streaming-rekognition.$region.$baseDomain:443" + } + + companion object { + private const val ISO_PARTITION_BASE_DOMAIN = "csp.hci.ic.gov" + private const val DEFAULT_BASE_DOMAIN = "amazonaws.com" + } }