Firebase云功能更改超时

Ame*_*eel 9 java networking android firebase google-cloud-functions

我在Android上使用Firebase Cloud Functions库,并使用getHttpsCallable调用云功能.

问题是函数需要10-15秒才能将结果返回给客户端,因此客户端会抛出异常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;
                    }
                }
            });
Run Code Online (Sandbox Code Playgroud)

如何更改超时,以便客户端在抛出异常之前等待更多?

注意.我没有使用OkHttp,Retrofit或默认的系统网络功能,我正在使用Firebase云功能库(getHttpsCallable)来调用该功能.

Bob*_*der 3

firebase-functions版本 16.3.0,于 2019 年 3 月 15 日发布,增加了配置超时的功能。