Closed honguri76 closed 6 hours ago
You can customize the Guzzle HTTP Client options with https://firebase-php.readthedocs.io/en/7.15.0/setup.html#setting-guzzle-config-options
However, requests to the Firebase APIs, including the Realtime Database, should take a few milliseconds - if requests are slow and the connection even times out, that must be a networking issue in your environment. You could try enabling debug logs in the Guzzle Config to hopefully get some hints as why that is.
Thank you for your reply. We checked the time using the code below.
$start = microtime(true); $update_value = array(); foreach( $post_data['topic_list'] AS $aRow ) { $micro_time_array = explode(" ", microtime()); $micro_time_last_value = explode(".", $micro_time_array[0]); $update_value[$server_text.$aRow.'/data'] = $data.'/'.substr($micro_time_array[1],6,9).'.'.substr($micro_time_last_value[1],0,6); } $database->getReference() ->update($update_value);
$end = microtime(true); $time = sprintf('%0.5f', $end - $start);
echo $time;
The time it takes for an update to complete is 500 milliseconds on average, but sometimes it takes 5000 milliseconds. In this case, does it mean that it is most likely a network problem in our system environment?
I think so, yes. If it's fast most of the time, but slow sometimes, there's nothing I can do in the code of the SDK to avoid that. That's why I can't "accept" this as a bug of the SDK.
Another possibility is that the realtime database API sometimes responds slowly (the request is fast, but the response is slow) - in that case this is a problem that might solve itself with time, when Firebase addresses the issue. That's where enabling debug logging via the Guzzle Client Config can help finding that out. If it's not your network connection, you should raise an issue with Firebase support directly (this SDK is not an official Firebase SDK)
Describe the bug
Hi. We use Firebase Admin SDK for PHP to use firebase realtime database.
$database->getReference() // this is the root reference ->update($updates);
When updating in the above manner, realtime database connection sometimes fails. Is there a way to find the cause of the connection failure?
I think the connection attempt times out after 15 seconds. Even if there is no timeout, the update attempt may take about 10 seconds.
Is there a way to change the timeout time?
Thank you.
Installed packages
PHP version and extensions
Steps to reproduce the issue.
require_once ('vendor/autoload.php'); use Kreait\Firebase\Factory; use Kreait\Firebase\Exception\FirebaseException; use Throwable;
$factory = (new Factory) ->withServiceAccount('../../.ssh/account.json') ->withDatabaseUri('https://databaseUri/');
$database = $factory->createDatabase();
$update_value = array(); foreach( $post_data['topic_list'] AS $aRow ) { $micro_time_array = explode(" ", microtime()); $micro_time_last_value = explode(".", $micro_time_array[0]); $update_value[$server_text.$aRow.'/data'] = $data.'/'.substr($micro_time_array[1],-4).'.'.substr($micro_time_last_value[1],0,6); }
$database->getReference() ->update($update_value);
Error message/Stack trace
Additional information
No response