Функции Firebase дают время ожидания на стороне клиента через 10 секунд - PullRequest
0 голосов
/ 10 июля 2019

Я использую getHttpsCallable для вызова облачной функции на Android, но функция возвращается с ошибкой FirebaseFunctionsException: DEADLINE_EXCEEDED, если это занимает более 10 секунд. Когда я проверил на firebase (на стороне сервера), он показывает, что функция завершена (без ошибок).

Примечание. Эта функция отлично работает на iOS и не работает на Android через 10 секунд

Я попробовал это решение здесь, так как проблема кажется похожей на эту , но по-прежнему не работает, если это занимает более 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: at 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"
 }
]

Есть что-то, чего мне здесь не хватает? Буду очень признателен за любую помощь.

1 Ответ

1 голос
/ 12 июля 2019

Это ошибка в клиентской библиотеке Android, связанная с различными типами таймаутов, доступных для OKHTTP.Вы можете прочитать об исправлении здесь:

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...