title: cURL SSL error with large file
body: <p>I'm trying to make some backup of my production server and send the backup compressed in tar.gz in another server. This was working fine before updating my server to php7.2-fpm (for HTTP2.0). </p>
  
  <p>I get this error :</p>
  
  <pre><code>Fatal error: Uncaught Exception: SSL read: error:00000000:lib(0):func(0):reason(0), errno 104
  </code></pre>
  
  <p>Here is the configuration of my two servers:</p>
  
  <p><strong>- Production server :</strong><br/>
  - System : Linux debian2 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64<br/>
  - Apache : Apache/2.4.33<br/>
  - Php : PHP Version 7.2.5-1 (with FPM api)<br/></p>
  
  <p><strong>- Backup server :</strong><br/>
  - System : Linux debian2 3.16.0-4-amd64 #1 SMP Debian 3.16.51-3 (2017-12-13) x86_64 <br/>
  - Apache : Apache/2.4.10<br/>
  - Php : PHP Version 7.1.13-1 (with Apache 2.0 handler)<br/></p>
  
  <p>The backup server is still with HTTP1, the production server use HTTP2 protocol.</p>
  
  <p>So in order to make my backup, i go to my root folder and just compress everything inside as a .tar.gz.</p>
  
  <p>To send the file here is the code i use :</p>
  
  <pre><code>/**
   * @brief Sends a file.
   * @param      Array          $data    The data to send (backup file path, file name)
   * @param      String|string  $action  The action (platformBackup, databaseBackup)
   * @return     Array|boolean
   */
  public static function sendFile(Array $data, String $action) : Array
  {
      $cFile = curl_file_create($data['file']);
      $data['save'] = $cFile;
  
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL,SERVER_SAVE_URL.'/'.SERVER_SAVE_TOKEN.'/' . $action . '/'.PLATEFORM_ID);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
      curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: multipart/form-data'));
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      $result = curl_exec($ch);
  
      if ($result === false)
      {
          throw new Exception(curl_error($ch), curl_errno($ch));
      }
  
      $result = json_decode($result, true);
      return $result;
  }
  </code></pre>
  
  <p>This works with a small file (less than 1Gb). But not with larger one.</p>
  
  <p>My first thought was a bad configuration of Apache and php7.2-fpm because everything worked great before.</p>
  
  <p>But i think that this is ok, here is the variables i changed in my php/7.2/fpm/php.ini :</p>
  
  <pre><code>max_execution_time = 10800 
  memory_limit = 1024M
  post_max_size = 10000M
  upload_max_filesize = 10000M
  </code></pre>
  
  <p>I also try to force them in the php/7.2/fpm/pool.d/www.conf but nothing change. </p>
  
  <p>Thanks in advance for your help !</p>
  
  <p><strong>EDIT :</strong><br/>
  <br/></p>
  
  <p>I update my backup server to Apache 2.4.33 and enable HTTP2.0 protocol with php7.2-fpm. When i try to backup i got a message in my error log :<br/></p>
  
  <pre><code>[Tue Jun 12 13:10:34.829260 2018] [proxy_fcgi:error] [pid 9092:tid 140388941666048] (70008)Partial results are valid but processing is incomplete: [client XXX.XXX.XXX.XXX:XXX] AH01075: Error dispatching request to : (reading input brigade)
  </code></pre>
  
  <p>From a php7.1-fpm server i got </p>
  
  <pre><code>503 Service Unavailable
  </code></pre>
  
  <p>From a php7.2-fpm i got :</p>
  
  <pre><code>Fatal error: Uncaught Exception: SSL read:error:00000000:lib(0):func(0):reason(0), errno 104
  </code></pre>
  
  <p>Since nothing worked with php and apache I told myself that the problem came from elsewhere, i watch my filesystem which is ext4 so no problem with large file and i try to send a backup with SCP which work great too. So for me the problem only come from PHP, Apache or cURL. </p>
  
  <p>As a reminder, the backup works for a little server (800mb) but not for larger one (3.4Gb)</p>
  
  <p><strong>EDIT 1 :</strong><br/>
  <br/>
  It seems that SSL is the problem, when i disable it on my backup server everything works. As a temporary solution i just encrypt the file with openssl with a generated key and send it to my backup server.</p>