0
votes

I am trying to use php with firebase

after installing the package "composer require kreait/firebase-php ^4.0"

and adjusting my firebase

it shows me that error:

Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: cURL error 35: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to ff64t.firebaseio.com:443 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:200 Stack trace: #0 C:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(155): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(105): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 C:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(Guz in C:\xampp\htdocs\dashboard\webservice\php_firebase\vendor\kreait\firebase-php\src\Firebase\Exception\ApiException.php on line 40

my php code is so simple:

 <?php
 require_once './vendor/autoload.php';
 use Kreait\Firebase\Factory;
     use Kreait\Firebase\ServiceAccount;
 $serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'/secret/clone-7ef2-642f.json');
 $firebase = (new Factory)
    ->withServiceAccount($serviceAccount)
    //->withDatabaseUri("https://ff64t.firebaseio.com")
    ->create();
    $database = $firebase->getDatabase();
    $ref = $database->getReference('users');
    $res = $ref->getChild('1z7ni171Hwgq8fdnandRNjfxBfw2')->getChild('name')->getValue();
    var_dump($res);

?>

so anyone has faced something like that and how to solve this problem

I've tried many solutions but none of them works.

I tried to reinstall curl and put it like system variable I also tried to add

curl_setopt($easy->handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

to make curl deal with IPV4... it gave me a new error which is:

Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\xampp\htdocs\dashboard\webservice\firebase_php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:201 Stack trace: #0 C:\xampp\htdocs\dashboard\webservice\firebase_php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(537): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 C:\xampp\htdocs\dashboard\webservice\firebase_php\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(152): GuzzleHttp\Handler\CurlFactory::retryFailedRewind(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Array) #2 C:\xam in C:\xampp\htdocs\dashboard\webservice\firebase_php\vendor\kreait\firebase-php\src\Firebase\Exception\ApiException.php on line 40

I also checked curl support and ssl from phpinfo

1
Hi! It would be great if you could tell us about some of the solutions you've tried already. - nicoqh
ok, I'm gonna add them in the post - HUS.97
firebase-php.readthedocs.io/en/5.3.0/… - also, if you‘re on at least PHP 7.2, you should migrate to release 5.x of the SDK 🤞 - jeromegamez
I tried the latest SDK version but it doesn't work - HUS.97

1 Answers

0
votes

According to the curl(1) manual page, an error code 35 is an SSL handshake failure:

EXIT CODES
  ...
  35     SSL connect error. The SSL handshaking failed.

You can try temporarily disabling the SSL certificate verification to see if that fixes the issue.

curl_setopt($handle, CURLOPT_VERIFYPEER, 0); // ***JUST A TEST! DO __NOT__ PUSH THIS TO PRODUCTION!***

If that does fix the issue, the reason is probably one of the two most common SSL handshake failures:

  1. A missing CA certificate on your host machine, meaning that cURL couldn't verify the certificate's authenticity.
  2. An expired certificate being presented by the machine you're connecting to.

If that does NOT fix the issue, the reason is probably:

  1. Your machine and the remote one couldn't negotiate a cipher suite and/or SSL version.
  2. Any number of other SSL errors.