【问题标题】:Firebase Functions gives Timeout on Client side after 10sFirebase 函数在 10 秒后在客户端提供超时
【发布时间】:2019-11-20 11:12:22
【问题描述】:

我正在使用 getHttpsCallable 在 Android 上调用云函数,但如果需要超过 10 秒,该函数会返回 FirebaseFunctionsException: DEADLINE_EXCEEDED 错误。当我检查 firebase(服务器端)时,它显示功能已完成(没有任何错误)。

注意:此功能在 iOS 上完美运行,在 Android 上 10 秒后失效

I tried this solution here as issue appears similar to this one 但如果超过 10 秒,功能仍然会失败。

我在 gradle 中使用最新的依赖项,

dependencies {
    // 
    implementation 'com.google.firebase:firebase-functions:18.0.0'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-auth:18.0.0'
    implementation 'com.google.firebase:firebase-storage:18.0.0'
}

她是我的职责,

HttpsCallableReference ref = mFunctions.getHttpsCallable("myFirebaseFunction");
ref.setTimeout(600, TimeUnit.SECONDS);
ref.call(Data)
    .addOnSuccessListener(new OnSuccessListener<HttpsCallableResult>() {
                @Override
                public void onSuccess(HttpsCallableResult httpsCallableResult) {
                    Gson jsonData = new Gson();
                    String json = jsonData.toJson(httpsCallableResult.getData());
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    e.printStackTrace();
                }
            });

这是堆栈跟踪日志,

W/System.err:com.google.firebase.functions.FirebaseFunctionsException:DEADLINE_EXCEEDED W/System.err:在 com.google.firebase.functions.FirebaseFunctions$2.onFailure(com.google.firebase:firebase-functions@@17.0.0:258) 在 okhttp3.RealCall$AsyncCall.execute(RealCall.java:215) 在 okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 在 java.lang.Thread.run(Thread.java:764) 引起:java.net.SocketTimeoutException:超时 在 okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:656) 在 okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:664) W/System.err:在 okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.java:153) 在 okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:131) 在 okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88) 在 okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 在 okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) 在 okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) W/System.err:在 okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 在 okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) 在 okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 在 okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 在 okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) 在 okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 在 okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) 在 okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) 在 okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) 在 okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254) 在 okhttp3.RealCall$AsyncCall.execute(RealCall.java:200) ... 4 更多

更新:Firebase 控制台日志

 [
 {
   "textPayload": "Function execution took 37358 ms, finished with status code: 200",
   "insertId": "000000-a5fca827-1905-4416-b053-206981a2e5a7",
   "resource": {
     "type": "cloud_function",
     "labels": {
       "function_name": "getBookContentByIdAndDate_v2",
       "project_id": "apotex360",
       "region": "us-central1"
     }
   },
   "timestamp": "2019-07-11T14:23:51.509329740Z",
   "severity": "DEBUG",
   "labels": {
     "execution_id": "5zxmtpmy8gho"
   },
   "logName": "projects/apotex360/logs/cloudfunctions.googleapis.com%2Fcloud-functions",
   "trace": "projects/apotex360/traces/98f9c62f094ff33f4e0524c9231fe126",
   "receiveTimestamp": "2019-07-11T14:23:57.750633081Z"
 },
 {
   "textPayload": "stream finished",
   "insertId": "000000-914deed7-d813-4f86-93d8-7f72d3377e1c",
   "resource": {
     "type": "cloud_function",
     "labels": {
       "project_id": "apotex360",
       "region": "us-central1",
       "function_name": "getBookContentByIdAndDate_v2"
     }
   },
   "timestamp": "2019-07-11T14:23:51.506Z",
   "severity": "INFO",
   "labels": {
     "execution_id": "5zxmtpmy8gho"
   },
   "logName": "projects/apotex360/logs/cloudfunctions.googleapis.com%2Fcloud-functions",
   "trace": "projects/apotex360/traces/98f9c62f094ff33f4e0524c9231fe126",
   "receiveTimestamp": "2019-07-11T14:23:57.750633081Z"
 },
 {
   "textPayload": "Function execution started",
   "insertId": "000000-409caeb7-96cd-4d27-b2b7-ed0546f919be",
   "resource": {
     "type": "cloud_function",
     "labels": {
       "project_id": "apotex360",
       "region": "us-central1",
       "function_name": "getBookContentByIdAndDate_v2"
     }
   },
   "timestamp": "2019-07-11T14:23:14.151990344Z",
   "severity": "DEBUG",
   "labels": {
     "execution_id": "5zxmtpmy8gho"
   },
   "logName": "projects/apotex360/logs/cloudfunctions.googleapis.com%2Fcloud-functions",
   "trace": "projects/apotex360/traces/98f9c62f094ff33f4e0524c9231fe126",
   "receiveTimestamp": "2019-07-11T14:23:20.439670300Z"
 }
]

这里有什么我遗漏的吗?非常感谢任何帮助。

【问题讨论】:

  • 我没有看到任何明显的错误,看起来与您链接的问题中的解决方案相同......只有其他建议可能是尝试this answer 中的方法。我承认并不理想。
  • 对面的功能码到底是什么?您的函数日志在 Firebase 控制台中说明了什么?
  • @DougStevenson 我用 firebase 控制台日志更新了问题。请看一看。

标签: android firebase google-cloud-functions


【解决方案1】:

这是 Android 客户端库中关于 OKHTTP 可用的不同类型超时的错误。您可以在此处阅读有关修复的信息:

https://github.com/firebase/firebase-android-sdk/issues/604

【讨论】:

  • 感谢您的回复。如果我能知道这个版本需要很长时间,那将会很有帮助。
  • 我不控制那个过程。您可以对该问题发表评论,看看是否有估算值。
  • 带有修复的更新版本 (firebase-functions:18.1.0)。现在工作正常。
猜你喜欢
  • 2011-04-13
  • 2018-02-15
  • 2020-04-07
  • 1970-01-01
  • 2017-11-27
  • 2013-06-11
  • 1970-01-01
  • 2015-02-07
  • 2017-10-19
相关资源
最近更新 更多