问题
I am trying to read firebase's data in PHP using cURL.
$curl = curl_init();
$url = "https://testing-3be52.firebaseio.com/test-Details.json";
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
$result = curl_exec ($curl);
$err_status = curl_error($curl);
curl_close ($curl);
$characters = json_decode($result,true);
//...logic goes here to display the data...
Above piece of code is working fine. However, it failing occasionally (or when the page is refreshed/loaded multiple times), with error "Failed to connect to testing-3be52.firebaseio.com port 443: Connection refused
".
This error automatically gets fixed after few minutes.
I googled a lot but couldn't find any solution. Your help will be much appreciated!
回答1:
It sounds like the server intermittantly just doesn't want to talk to you. If so, there's probably not too much you can do from your PHP client.
SUGGESTION:
Increase your connect timeout >> 5
来源:https://stackoverflow.com/questions/48456535/failed-to-connect-to-testing-3be52-firebaseio-com-port-443-connection-refused