-
Thanks for a really great library @mobizt. I am confused about the RTDB async write methods. I have an ESP8266 PID application where I read the setpoint from RTDB along with some other things using the multipath stream setup and concurrently write sensor values to the RTDB using setInt() and setFloat() at a particular frequency. This works perfectly with setInt() and setFloat(), but if the wifi is sketchy, the synchronous writes can take a long time to complete or timeout, disturbing my control loop. So I would like to use setFloatAsync() and setIntAsync(). I'm not sure I understand the documentation correctly. I separated my readstream and writes to use separate FirebaseData objects. Then, if I just replace setFloat() and setInt() with setFloatAsync() and setIntAsync() in the control loop at the required frequency (every two seconds), the methods return immediately as expected without any error code, but there is no update to the database. I must be missing something about how to give the async writes time to execute. Do I need to do something more to let them run? My control loop does not have any delays; it just reads sensors, does the PID calculation, then checks if it's time to update the display or the RTDB. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
This example comment stated how about async action Firebase-ESP-Client/examples/RTDB/FastSend/FastSend.ino Lines 114 to 116 in cb7ea94 It returns true as long as the connection established (socket is stay open or session is alive) then you can continuously write data to database without to wait for response which error will not known. The operation is not like async TCP client that can handle multiple sockets connection as it does not support in core WiFiClientSecure. The async function returns immediately after the request sent and the server response is ignored. If the connection closed due to internet connection issue or timed out, the new connection process takes time due to SSL handshake process as usual. |
Beta Was this translation helpful? Give feedback.
-
To read/store data more quickly, you may consider the following concerns. The speed of data transfer depends on many factors as this library works with REST API that used http protocol to transport the data. It involved sending the request and receiving the sever response. The request and response consisted of header and payload. The authentication token when is used as the part of payload will be increased the request header size. If you set the security rules of your RTDB to allow public read and write i.e. .read and .write keys have the value of true, which no auth token is needed you can rapidly read and write database data but it is not supported in this library because of the privacy concerns. |
Beta Was this translation helpful? Give feedback.
-
Thanks @mobizt ! I did read that comment. Also, I'm not sure, but I don't think speed of transfer is a problem. The problem is that the async methods do not update the database at all. I was able to reproduce the problem with your FastSend example. The main difference is that I am using a service account/oauth. Is that a problem? Please see below.
With |
Beta Was this translation helpful? Give feedback.
-
The authentication method is not an issue. The error which I just discovered is the changes in Google server side which breaks the operation of using silent print parameter to return empty response payload and it should return 204 No Content status code but it is currently return 404 Not Found status code which is not valid return. Now all functions that use this silent print parameter will be affected by this Google issue included updateNodeSilent, all async functions, pathExisted, setBlob, setBlobAsync, setFile, setFileAsync and restore. |
Beta Was this translation helpful? Give feedback.
-
I will temporary remove silent print parameter from those functions to fix the issue in the next update, the side effect is the data bandwidth was not reduced as usual. |
Beta Was this translation helpful? Give feedback.
The authentication method is not an issue.
The error which I just discovered is the changes in Google server side which breaks the operation of using silent print parameter to return empty response payload and it should return 204 No Content status code but it is currently return 404 Not Found status code which is not valid return.
Now all functions that use this silent print parameter will be affected by this Google issue included updateNodeSilent, all async functions, pathExisted, setBlob, setBlobAsync, setFile, setFileAsync and restore.