【问题标题】:AWS Appsync Cache miss and 403 Error on New Device新设备上的 AWS Appsync 缓存未命中和 403 错误
【发布时间】:2019-08-08 08:32:05
【问题描述】:

我正在开发基于 AWS Amplify 的应用程序。在第二台本地设备上进行测试时,我注意到每个 graphQL 查询都失败了,返回缓存未命中和/或网络错误。很可能取决于使用哪个 AppSyncResponseFetchers。我已经尝试过网络优先和仅网络,但查询仍然失败。

如果我在模拟器或其他设备上打开应用程序,则不会出现任何错误,因此我有理由相信这不是配置错误。我已尝试卸载并重新安装该应用程序,但它不起作用。

关于这个问题的根源有什么想法吗?

2019-03-17 17:24:44.718 32349-32559/com.myapp.android E/myapp.AWSDataService: Error during GraphQL Operation: Cache miss for operation com.amazonaws.amplify.generated.graphql.AmNewUserQuery@f7cd3d7
com.apollographql.apollo.exception.ApolloException: Cache miss for operation com.amazonaws.amplify.generated.graphql.AmNewUserQuery@f7cd3d7
    at com.apollographql.apollo.internal.interceptor.ApolloCacheInterceptor.resolveFromCache(ApolloCacheInterceptor.java:138)
    at com.apollographql.apollo.internal.interceptor.ApolloCacheInterceptor.access$100(ApolloCacheInterceptor.java:53)
    at com.apollographql.apollo.internal.interceptor.ApolloCacheInterceptor$1.run(ApolloCacheInterceptor.java:78)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)
2019-03-17 17:24:44.720 32349-32600/com.myapp.android D/RetryInterceptor: Encountered non-retriable error. Returning response    
2019-03-17 17:24:44.721 32349-32600/com.myapp.android E/myapp.AWSDataService: Error during GraphQL Operation: HTTP 403 
        com.apollographql.apollo.exception.ApolloHttpException: HTTP 403 
            at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor.parse(ApolloParseInterceptor.java:147)
            at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor.access$100(ApolloParseInterceptor.java:54)
            at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor$1.onResponse(ApolloParseInterceptor.java:83)
            at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor$1$1.onResponse(ApolloServerInterceptor.java:110)
            at okhttp3.RealCall$AsyncCall.execute(RealCall.java:141)
            at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
            at java.lang.Thread.run(Thread.java:764)

编辑: Appsync 版本:2.7+(也是 2.7.0)

设备 1:三星 Galaxy S9+ Android 28(工作中)

设备 2:HTC 10 Android 26(失败)

模拟器 1:Pixel 2 Android 27(工作中)

模拟器 1:Pixel 2 Android 25(工作中)

我之前在我的主设备上看到过这个问题,因为我之前在主设备上进行了特定查询。显然,我不知道到底是什么导致了这个问题,但我能够通过登录我的 AWS 账户并重新保存解析器来解决它。无需对解析器进行任何功能更改,它就重新开始工作。

编辑 2:

使用 android 调试器,403 错误是由 InvalidSignatureException, "Error from cloudfront" 引起的

可能相关:Amazon API Gateway IAM authenticated example with generated JS SDK

【问题讨论】:

  • appsync的认证方式是什么? (iam / cognito / apikey)?
  • IAM,特别是使用联合身份和 Facebook 登录。
  • 您能否在触发 graphql 查询之前确认您已通过身份验证?
  • 我相信是的。我的 UserStateDetails 设置为 SIGNED_IN,getIdentityId 返回用户的 CognitoIdentityId。
  • 嗯,您可以尝试在您的应用程序中使用具有该认知令牌的其他 AWS 服务吗?例如列出 S3 存储桶中的对象(您必须允许 cognito 用户拥有 s3 权限)。只是为了确保这不是权限问题

标签: android amazon-web-services graphql aws-appsync aws-amplify


【解决方案1】:

我遇到了同样的问题,并且费了很大力气才找到问题的原因。然后我检查并发现我的 API 密钥已过期,因此我重新创建了我的 API 密钥并解决了错误。

【讨论】:

    猜你喜欢
    • 2018-12-09
    • 2021-05-02
    • 2012-04-21
    • 2019-06-10
    • 2015-07-09
    • 2020-11-23
    • 2021-01-12
    • 1970-01-01
    • 2018-11-17
    相关资源
    最近更新 更多