"state": "SERVER ERROR", "Request has invalid parameters", FaceLivenessDetector

0

Luego del start video check en produccion con next.js sale este error: "Server issue. Cannot complete check due to server issue" { "state": "SERVER_ERROR", "error": { "name": "ValidationException", "message": "Request has invalid parameters", "$fault": "client", "$metadata": { "httpStatusCode": undefined, "requestId": undefined, "extendedRequestId": undefined, "cfId": undefined }, "stack": "ValidationException\n , "constructor": { "name": "ValidationException", "prototype": { "name": "ValidationException", "message": "", "constructor": "Function", "prototype": "Object" } }, "prototype": { "constructor": { "name": "v6" }, "prototype": "vC" } } } si tengo este componente en next.js: import { useEffect, useState } from "react"; import { FaceLivenessDetector } from "@aws-amplify/ui-react-liveness"; import { Loader, ThemeProvider, withAuthenticator } from "@aws-amplify/ui-react"; import { Exo } from "next/font/google"; import { ApiServer } from "@/apis";

const exo = Exo({ subsets: ["latin"], });

export const Face = () => { const [loading, setLoading] = useState<boolean>(true); const [createLivenessApiData, setCreateLivenessApiData] = useState<{ sessionId: string; } | null>(null);

useEffect(() => {

const fetchCreateLiveness: () => Promise<void> = async () => {
  try {

    const clientRequestToken = crypto.randomUUID();
    const response = await ApiServer.post(`/start_liveness_session/?client_request_token=${clientRequestToken}`, {
      client_request_token: clientRequestToken,
    });
    const data = await response.data;
    setCreateLivenessApiData(data);
    setLoading(false);
  } catch (error) {
    console.error("Error en fetchCreateLiveness:", error);

    setLoading(false);
  }
};

fetchCreateLiveness();

}, []);

const handleAnalysisComplete: () => Promise<void> = async () => { const response = await ApiServer.get( /get_liveness_results/${createLivenessApiData?.sessionId} ); const data = await response.data; console.log(data); if (data.isLive) { console.log("User is live"); } else { console.log("User is not live"); } };

return ( <div className={exo.className}> <ThemeProvider> {loading ? ( <Loader /> ) : ( <FaceLivenessDetector sessionId={createLivenessApiData?.sessionId || ""} region="us-east-1" onAnalysisComplete={handleAnalysisComplete} onError={(error) => { console.error(error); }} /> )} </ThemeProvider> </div> ); };

export default withAuthenticator(Face); Enter image description here

asked a month ago35 views
1 Answer
0

The error you're encountering suggests that there's an issue with the parameters being passed to the Face Liveness detection service. This could be due to several reasons:

  1. Invalid Session ID: Ensure that the sessionId you're passing to the FaceLivenessDetector component is valid and correctly formatted.

  2. Region Mismatch: Verify that the region you're using ("us-east-1" in your code) is correct and supports the Face Liveness feature. Not all AWS regions support this feature.

  3. Expired Session: Face Liveness sessions have a limited lifespan. If too much time passes between creating the session and starting the detection, the session may expire.

  4. Incorrect API Call: Double-check that your API call to start the liveness session is correctly implemented and includes all required parameters.

  5. Permissions: Ensure that your AWS credentials have the necessary permissions to use the Face Liveness feature.

To troubleshoot:

  1. Log the full error message and any additional details returned by the API.

  2. Verify that the sessionId is being correctly passed from your API response to the FaceLivenessDetector component.

  3. Check that your AWS SDK and @aws-amplify/ui-react-liveness package versions are up-to-date and compatible.

  4. Ensure that the client-side code has the necessary permissions to call the Face Liveness API.

  5. Review your API implementation for starting the liveness session to make sure it's correctly calling the AWS Rekognition StartFaceLivenessSession API.

If the issue persists after these checks, you may need to review your server-side implementation of the liveness session creation and potentially contact AWS support for further assistance.

Sources
前端开始活体检测时,遇到Request has invalid parameters的报错 | AWS re:Post
StartFaceLivenessSession - Amazon Rekognition
Rekognition Faceliveness Issues | AWS re:Post

profile picture
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions