android - 新设备上的 AWS Appsync 缓存未命中和 403 错误

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

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

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

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

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:Samsung Galaxy S9+ Android 28(工作中)

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

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

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

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

编辑 2:

使用 android 调试器,403 错误是由 InvalidSignatureException,“来自云端的错误”引起的

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

最佳答案

我遇到了同样的问题,并且努力寻找问题的原因。然后我检查发现我的 API key 已经过期,所以我重新创建了我的 API key 并且错误被解决了。

关于android - 新设备上的 AWS Appsync 缓存未命中和 403 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55213474/

相关文章:

android - 即使应用程序被销毁,AsyncTask 也将始终运行?

java - 停止后媒体播放器不启动

amazon-web-services - 在 AWS Glue 中聚合数据帧的好方法是什么

amazon-web-services - Lambda API 结果作为在 Cloud Formation 中创建 AWS 资源的条件

graphql - 使用 GraphQL 查询获取最大值和最小值

javascript - 这个操作是什么意思? {| ... |} 和 +attrName

node.js - 带有明确错误 : Query. 的 GraphQL 示例字段类型必须是输出类型,但得到:[object Object]

android - 在 BluetoothAdapter 的 onScanResult 上防止 NPE

android - 如何使用onDraw(Canvas)获取WebView的位图快照(Android)

android - 如何阻止连接到 AWS RDS 实例的不需要的设备?