Firebase Cloud Functions Change Timeout(Firebase 云函数更改超时)
问题描述
我在 Android 上使用 Firebase Cloud Functions 库,并使用 getHttpsCallable
调用云函数.
I'm using Firebase Cloud Functions library on Android, and using getHttpsCallable
to call a cloud function.
问题是函数需要10-15秒才能将结果返回给客户端,所以客户端抛出异常java.net.SocketTimeoutException: timeout
.
The problem is that the function needs 10-15 seconds to return the result back to the client, so the client throws an exception java.net.SocketTimeoutException: timeout
.
代码
// Create the arguments to the callable function.
Map<String, Object> data = new HashMap<>();
data.put("info", info);
mFunctions.getHttpsCallable(function)
.call(data)
.continueWith(new Continuation<HttpsCallableResult, String>() {
@Override
public String then(@NonNull Task<HttpsCallableResult> task) {
// This continuation runs on either success or failure, but if the task
// has failed then getResult() will throw an Exception which will be
// propagated down.
if (task.isSuccessful()) {
String result = (String) task.getResult().getData();
Log.v(Constants.LOG_TAG, result);
return result;
} else {
// The condition never was true, always logs the exception.
Exception e = task.getException();
Log.e(Constants.LOG_TAG, "Failed to join multiplayer room.", e);
return null;
}
}
});
如何更改超时,以便客户端在抛出异常之前等待更多时间?
How can I change the timeout so the client would wait more before throwing the exception?
注意.我没有使用 OkHttp、Retrofit 或默认系统网络功能,我使用 Firebase 云函数库 (getHttpsCallable
) 来调用该函数.
Note. I'm not using OkHttp, Retrofit or the default system Networking functions, I'm using Firebase Cloud Functions library (getHttpsCallable
) to call the function.
推荐答案
firebase-functions
16.3.0 版,2019 年 3 月 15 日发布,增加了 配置超时时间.
firebase-functions
version 16.3.0, released 15 Mar 2019, adds the ability to configure the timeout.
这篇关于Firebase 云函数更改超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Firebase 云函数更改超时


基础教程推荐
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01