mobizt / Firebase-ESP-Client

[DEPRECATED]🔥Firebase Arduino Client Library for ESP8266, ESP32 and RP2040 Pico. The complete, fast, secured and reliable Firebase Arduino client library that supports RTDB, Cloud Firestore, Firebase and Google Cloud Storage, Cloud Messaging and Cloud Functions for Firebase.
MIT License
471 stars 100 forks source link

Non-blocking token request method #598

Closed import-tiago closed 9 months ago

import-tiago commented 9 months ago

I have a project in which the ESP32 can eventually be configured on a Wi-Fi network without internet access (and it's fine for my application);

But, when using Firebase-ESP-Client, the tokenProcessingTask() will hangs the execution of the entire application because it has a while() that infinitely tries to obtain the token.

My suggestion is to add an option like "config.abort_connection_if_token_fail = true" and "config.token_request_attempts = 5" (examples only), to allow use cases like mine to continue working (even if it means being without Firebase services available).

I will modify for my own use, but the official solution may help others.

mobizt commented 9 months ago

It is about http request-response process which of course it is blocking for a while which is actually done once at a time.

The process utilized the states in a predetermined condition loop instead of infinite loop as you may feel that is why the callback is presented.

The time out is not necessary as long as you can control the execution of Firebase.ready().

FYi, this is not async operation library, the time out was done internally with TCP client and you can change it (see basic example comment).

mobizt commented 9 months ago

The Async Firebase Client library is under development.