Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Functions Change Timeout

I'm using Firebase Cloud Functions library on Android, and using getHttpsCallable to call a cloud function.

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.

Code

    // 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?

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.

like image 379
Ameer Taweel Avatar asked Jun 21 '18 14:06

Ameer Taweel


People also ask

How do I schedule a firebase cloud function?

If you want to schedule functions to run at specified times, use functions. pubsub. schedule(). onRun() This convenience method creates a Pub/Sub topic and uses Cloud Scheduler to trigger events on that topic, ensuring that your function runs on the desired schedule.

How much memory is allocated to a cloud function by default?

By default, the memory allocated for a function is 256MB or 256 MiB depending on the Cloud Functions product version.


1 Answers

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

like image 127
Bob Snyder Avatar answered Oct 12 '22 23:10

Bob Snyder