Sometimes it takes a long time for getInt to get the value #195
-
I have a program that, depending on the value of a variable 'control', has to update the value of another field 'data' per second. I read 'control' every second, and when it goes to 1, I send 'data' every second and I read 'control' every 3 seconds, because if it goes back to 0 I have to stop sending 'data'. Everything works fine, but the operation of reading 'control' sometimes takes longer than normal, I don't know why, and prevents me from writing 'data' in time, causing that, once I have been able to read 'control', all the dependent registers are written. Is there a way to improve the reading efficiency of 'control' to avoid the queuing of 'data'? Is it possible to write to 'data' and not be affected by the getInt operation of 'control'? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
If you want to manually reading the data while storing the data, you can use different FirebaseData objects. One FirebaseData object can use for storing the data or fastest storing as in this example Another FirebaseData object can use for reading the data. The time for first connection with server depends on the SSL handshake operation time (almost 1 second or more ) and time to send the request (depends on payload and auth token size). Normally the TCP (http) session will keep open to reuse, the subsequent request can be performed faster in few hundreds ms without waiting for the SSL handshake as in new connection. The library will close the TCP session that exceeds 3 minutes, the subsequent request needs to do SSL handshake again, in this case you may feel that the the data reading or storing is slower. But polling read the data is still not efficient as it involved sending the request and wait for server response which the request payload may be large as 1k depending on the authentication used and can be slow and costs your network bandwidth, you can read this for details. I recommend to use Stream instead as why it called Realtime database. See this examples for how to use it. |
Beta Was this translation helpful? Give feedback.
-
Please remember, the library works on REST API instead of web socket which not supported in this environment and platform, which the time for sending each request to read/store data will always depending on the payload and auth token size. |
Beta Was this translation helpful? Give feedback.
-
Ok, I realised that I already had two different FirebaseData objects, so I thought maybe we could try modifying these two parameters:
What would be the optimal values to perform this operation in 1s? |
Beta Was this translation helpful? Give feedback.
If you want to manually reading the data while storing the data, you can use different FirebaseData objects.
One FirebaseData object can use for storing the data or fastest storing as in this example
Another FirebaseData object can use for reading the data.
The time for first connection with server depends on the SSL handshake operation time (almost 1 second or more ) and time to send the request (depends on payload and auth token size).
Normally the TCP (http) session will keep open to reuse, the subsequent request can be performed faster in few hundreds ms without waiting for the SSL handshake as in new connection.
The library will close the TCP session that exceeds 3 minutes, the subse…