I am using getHttpsCallable
to call a cloud function on Android but the function returns with FirebaseFunctionsException: DEADLINE_EXCEEDED
error if it takes more than 10 seconds. When I checked on firebase (Server side), it shows function completed (without any ERROR).
Note: This function works perfectly on iOS and fails on Android after 10 seconds
I tried this solution here as issue appears similar to this one but still fucntion fails if it takes more than 10s.
I am using latest dependencies in 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'
}
Hers is my function,
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();
}
});
Here is the stack-trace log,
W/System.err: com.google.firebase.functions.FirebaseFunctionsException: DEADLINE_EXCEEDED W/System.err: at com.google.firebase.functions.FirebaseFunctions$2.onFailure(com.google.firebase:firebase-functions@@17.0.0:258) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:215) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) Caused by: java.net.SocketTimeoutException: timeout at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:656) at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:664) W/System.err: at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.java:153) at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:131) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:200) ... 4 more
Update: Firebase Console log
[
{
"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"
}
]
Is there something that I am missing here? I would really appreciate any help.