Firebase云功能更改超时 [英] Firebase Cloud Functions Change Timeout

查看:67
本文介绍了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 Cloud Functions库(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,配置超时时间.

firebase-functions version 16.3.0, released 15 Mar 2019, adds the ability to configure the timeout.

这篇关于Firebase云功能更改超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆