RequestException: cURL error 23: Unrecognized content encoding type

Nextcloud version: 19.0.1
Operating system and version: Ubuntu 18.04.4 LTS
Apache or nginx version: nginx/1.18.0
PHP version: 7.3

The issue you are facing: Do not see the app store within nextcloud’s settings; only “Your apps”, “Active apps”, “Disabled apps”, “App bundles”, “Featured apps” and “Developer documentation”.

Btw: The “Developer documentation” link does not work in 19.0.1 :wink:

Is this the first time you’ve seen this error?: Y

Steps to replicate it:

  1. wget https://download.nextcloud.com/server/releases/nextcloud-19.0.1.tar.bz2
  2. tar -xf nextcloud-19.0.1.tar.bz2
  3. do the default install procedure
  4. go to menu (click on the top right user icon) > Apps
  5. app store is not listed as well as errors in nextcloud.log

The output of your Nextcloud log in Admin > Logging:

GuzzleHttp\Exception\RequestException: cURL error 23: Unrecognized content encoding type. libcurl understands identity content encodings. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

The output of your config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'instanceid' => 'ocpu8o03ej5y',
  'passwordsalt' => 'WHATaSalt',
  'secret' => 'wellthisissecret',
  'trusted_domains' =>
  array (
    0 => 'nextcloud.domain.tld',
  ),
  'datadirectory' => '/www/nextcloud.domain.tld/data',
  'dbtype' => 'mysql',
  'version' => '19.0.1.1',
  'overwrite.cli.url' => 'https://nextcloud.domain.tld',
  'dbname' => 'cooldbname',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'coolusername',
  'dbpassword' => 'secretpwd',
  'installed' => true,
  'mail_from_address' => 'mailuser',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'domain.tld',
  'mail_smtphost' => 'localhost',
  'mail_smtpport' => '25',
);

The output of your Apache/nginx/system log in /var/log/____:
There’s nothing in the nginx error.log and all good (200) in the nginx access.log.
But instead in the nextcloud.log:
(each apps call produces 4 log entries, like the following one)

{"reqId":"b5xo7DOfEWWbymPwsEqm","level":2,"time":"2020-07-21T12:28:26+00:00","remoteAddr":"123.123.123.123","user":"mycooladminuser","app":"appstoreFetcher","method":"GET","url":"/settings/apps","message":{"Exception":"GuzzleHttp\\Exception\\RequestException","Message":"cURL error 23: Unrecognized content encoding type. libcurl understands identity content encodings. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)","Code":200,"Trace":[{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/CurlFactory.php","line":155,"function":"createRejection","class":"GuzzleHttp\\Handler\\CurlFactory","type":"::","args":[{"sink":{"__class__":"GuzzleHttp\\Psr7\\Stream"},"headers":["Date: Tue, 21 Jul 2020 12:28:26 GMT","Server: nginx/1.14.0 (Ubuntu)","Content-Type: application/json","Vary: Accept-Encoding,Accept-Language,Cookie","Allow: GET, HEAD, OPTIONS","ETag: W/\"2020-07-21 11:09:52.985039+00:00\"","Content-Language: en","X-Frame-Options: SAMEORIGIN","Content-Security-Policy: connect-src 'self'; img-src *; style-src 'self'; font-src 'self'; script-src 'self'; form-action 'self'; default-src 'none'","X-Content-Type-Options: nosniff","X-XSS-Protection: 1; mode=block","X-Cache-Status: HIT","X-Cache-Date: Tue, 21 Jul 2020 11:28:01 GMT","Content-Encoding: gzip","Transfer-Encoding: chunked"],"response":{"__class__":"GuzzleHttp\\Psr7\\Response"},"request":{"__class__":"GuzzleHttp\\Psr7\\Request"},"options":{"verify":"/www/nextcloud.domain.tld/data/files_external/rootcerts.crt","timeout":60,"synchronous":true,"handler":{"__class__":"GuzzleHttp\\HandlerStack"},"allow_redirects":{"max":5,"protocols":["http","https"],"strict":false,"referer":false,"track_redirects":false},"http_errors":true,"decode_content":true,"cookies":false,"idn_conversion":true},"errno":23,"onHeadersException":null,"__class__":"GuzzleHttp\\Handler\\EasyHandle"},{"errno":23,"error":"Unrecognized content encoding type. libcurl understands identity content encodings.","appconnect_time":0.136836,"url":"https://apps.nextcloud.com/api/v1/apps.json","content_type":"application/json","http_code":200,"header_size":621,"request_size":121,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.146867,"namelookup_time":0.106982,"connect_time":0.115678,"pretransfer_time":0.136849,"size_upload":0,"size_download":0,"speed_download":0,"speed_upload":0,"download_content_length":-1,"upload_content_length":-1,"starttransfer_time":0.146753,"redirect_time":0,"redirect_url":"","primary_ip":"176.9.217.53","certinfo":[],"primary_port":443,"local_ip":"46.163.92.2","local_port":53092,"http_version":2,"protocol":2,"ssl_verifyresult":0,"scheme":"HTTPS","curl_version":"7.64.1"}]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/CurlFactory.php","line":105,"function":"finishError","class":"GuzzleHttp\\Handler\\CurlFactory","type":"::","args":[{"__class__":"GuzzleHttp\\Handler\\CurlHandler"},{"sink":{"__class__":"GuzzleHttp\\Psr7\\Stream"},"headers":["Date: Tue, 21 Jul 2020 12:28:26 GMT","Server: nginx/1.14.0 (Ubuntu)","Content-Type: application/json","Vary: Accept-Encoding,Accept-Language,Cookie","Allow: GET, HEAD, OPTIONS","ETag: W/\"2020-07-21 11:09:52.985039+00:00\"","Content-Language: en","X-Frame-Options: SAMEORIGIN","Content-Security-Policy: connect-src 'self'; img-src *; style-src 'self'; font-src 'self'; script-src 'self'; form-action 'self'; default-src 'none'","X-Content-Type-Options: nosniff","X-XSS-Protection: 1; mode=block","X-Cache-Status: HIT","X-Cache-Date: Tue, 21 Jul 2020 11:28:01 GMT","Content-Encoding: gzip","Transfer-Encoding: chunked"],"response":{"__class__":"GuzzleHttp\\Psr7\\Response"},"request":{"__class__":"GuzzleHttp\\Psr7\\Request"},"options":{"verify":"/www/nextcloud.domain.tld/data/files_external/rootcerts.crt","timeout":60,"synchronous":true,"handler":{"__class__":"GuzzleHttp\\HandlerStack"},"allow_redirects":{"max":5,"protocols":["http","https"],"strict":false,"referer":false,"track_redirects":false},"http_errors":true,"decode_content":true,"cookies":false,"idn_conversion":true},"errno":23,"onHeadersException":null,"__class__":"GuzzleHttp\\Handler\\EasyHandle"},{"__class__":"GuzzleHttp\\Handler\\CurlFactory"}]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/CurlHandler.php","line":43,"function":"finish","class":"GuzzleHttp\\Handler\\CurlFactory","type":"::","args":[{"__class__":"GuzzleHttp\\Handler\\CurlHandler"},{"sink":{"__class__":"GuzzleHttp\\Psr7\\Stream"},"headers":["Date: Tue, 21 Jul 2020 12:28:26 GMT","Server: nginx/1.14.0 (Ubuntu)","Content-Type: application/json","Vary: Accept-Encoding,Accept-Language,Cookie","Allow: GET, HEAD, OPTIONS","ETag: W/\"2020-07-21 11:09:52.985039+00:00\"","Content-Language: en","X-Frame-Options: SAMEORIGIN","Content-Security-Policy: connect-src 'self'; img-src *; style-src 'self'; font-src 'self'; script-src 'self'; form-action 'self'; default-src 'none'","X-Content-Type-Options: nosniff","X-XSS-Protection: 1; mode=block","X-Cache-Status: HIT","X-Cache-Date: Tue, 21 Jul 2020 11:28:01 GMT","Content-Encoding: gzip","Transfer-Encoding: chunked"],"response":{"__class__":"GuzzleHttp\\Psr7\\Response"},"request":{"__class__":"GuzzleHttp\\Psr7\\Request"},"options":{"verify":"/www/nextcloud.domain.tld/data/files_external/rootcerts.crt","timeout":60,"synchronous":true,"handler":{"__class__":"GuzzleHttp\\HandlerStack"},"allow_redirects":{"max":5,"protocols":["http","https"],"strict":false,"referer":false,"track_redirects":false},"http_errors":true,"decode_content":true,"cookies":false,"idn_conversion":true},"errno":23,"onHeadersException":null,"__class__":"GuzzleHttp\\Handler\\EasyHandle"},{"__class__":"GuzzleHttp\\Handler\\CurlFactory"}]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/Proxy.php","line":28,"function":"__invoke","class":"GuzzleHttp\\Handler\\CurlHandler","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/Proxy.php","line":51,"function":"GuzzleHttp\\Handler\\{closure}","class":"GuzzleHttp\\Handler\\Proxy","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php","line":37,"function":"GuzzleHttp\\Handler\\{closure}","class":"GuzzleHttp\\Handler\\Proxy","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Middleware.php","line":29,"function":"__invoke","class":"GuzzleHttp\\PrepareBodyMiddleware","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/RedirectMiddleware.php","line":70,"function":"GuzzleHttp\\{closure}","class":"GuzzleHttp\\Middleware","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Middleware.php","line":59,"function":"__invoke","class":"GuzzleHttp\\RedirectMiddleware","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/HandlerStack.php","line":71,"function":"GuzzleHttp\\{closure}","class":"GuzzleHttp\\Middleware","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php","line":361,"function":"__invoke","class":"GuzzleHttp\\HandlerStack","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php","line":163,"function":"transfer","class":"GuzzleHttp\\Client","type":"->","args":["*** sensitive parameter replaced ***","*** sensitive parameter replaced ***"]},{"file":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Client.php","line":183,"function":"requestAsync","class":"GuzzleHttp\\Client","type":"->","args":["get",{"__class__":"GuzzleHttp\\Psr7\\Uri"},{"verify":"/www/nextcloud.domain.tld/data/files_external/rootcerts.crt","timeout":60,"synchronous":true,"handler":{"__class__":"GuzzleHttp\\HandlerStack"},"allow_redirects":{"max":5,"protocols":["http","https"],"strict":false,"referer":false,"track_redirects":false},"http_errors":true,"decode_content":true,"cookies":false,"idn_conversion":true,"_conditional":{"User-Agent":"GuzzleHttp/6.5.1 curl/7.64.1 PHP/7.3.20-1+ubuntu18.04.1+deb.sury.org+1"}}]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/Http/Client/Client.php","line":228,"function":"request","class":"GuzzleHttp\\Client","type":"->","args":["get","https://apps.nextcloud.com/api/v1/apps.json",{"verify":"/www/nextcloud.domain.tld/data/files_external/rootcerts.crt","timeout":60,"headers":{"Accept-Encoding":"gzip","User-Agent":"Nextcloud Server Crawler"},"synchronous":true}]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/App/AppStore/Fetcher/Fetcher.php","line":109,"function":"get","class":"OC\\Http\\Client\\Client","type":"->","args":["https://apps.nextcloud.com/api/v1/apps.json",{"timeout":60,"headers":{"Accept-Encoding":"gzip"}}]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/App/AppStore/Fetcher/AppFetcher.php","line":86,"function":"fetch","class":"OC\\App\\AppStore\\Fetcher\\Fetcher","type":"->","args":["",""]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/App/AppStore/Fetcher/Fetcher.php","line":173,"function":"fetch","class":"OC\\App\\AppStore\\Fetcher\\AppFetcher","type":"->","args":["",""]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/Installer.php","line":408,"function":"get","class":"OC\\App\\AppStore\\Fetcher\\Fetcher","type":"->","args":[]},{"file":"/www/nextcloud.domain.tld/nextcloud/apps/settings/lib/Controller/AppSettingsController.php","line":153,"function":"isUpdateAvailable","class":"OC\\Installer","type":"->","args":["updatenotification"]},{"file":"/www/nextcloud.domain.tld/nextcloud/apps/settings/lib/Controller/AppSettingsController.php","line":136,"function":"getAppsWithUpdates","class":"OCA\\Settings\\Controller\\AppSettingsController","type":"->","args":[]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":170,"function":"viewApps","class":"OCA\\Settings\\Controller\\AppSettingsController","type":"->","args":[]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":100,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Settings\\Controller\\AppSettingsController"},"viewApps"]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/AppFramework/App.php","line":137,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Settings\\Controller\\AppSettingsController"},"viewApps"]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php","line":47,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Settings\\Controller\\AppSettingsController","viewApps",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"category":"","id":"","_route":"settings.AppSettings.viewApps"}]},{"function":"__invoke","class":"OC\\AppFramework\\Routing\\RouteActionHandler","type":"->","args":[{"category":"","id":"","_route":"settings.AppSettings.viewApps"}]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/private/Route/Router.php","line":297,"function":"call_user_func","args":[{"__class__":"OC\\AppFramework\\Routing\\RouteActionHandler"},{"category":"","id":"","_route":"settings.AppSettings.viewApps"}]},{"file":"/www/nextcloud.domain.tld/nextcloud/lib/base.php","line":1007,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/settings/apps"]},{"file":"/www/nextcloud.domain.tld/nextcloud/index.php","line":37,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/CurlFactory.php","Line":201,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0","version":"19.0.1.1"}

We’ve got 2 installations of nextcloud on this server (18.0.7 + 19.0.1), both do have the same problem.
The server is able to cURL https://apps.nextcloud.com/api/v1/categories.json both via command line as well as via PHP.
So there’s no firewall or cURL problem - maybe a php-curl issue?
(Works great on my local dev machine…)

I don’t know what’s wrong… :frowning:
Any idea?

Thanks in advance! :slight_smile:

If I debug the CurlFactory.php (/www/nextcloud.domain.tld/nextcloud/3rdparty/guzzlehttp/guzzle/src/Handler/CurlFactory.php) and var_export() the $easy->response as well as the $easy->errno within the finish() method, I get this output:

GuzzleHttp\Psr7\Response::__set_state(array(
   'reasonPhrase' => 'OK',
   'statusCode' => 200,
   'headers' => 
  array (
    'Date' => 
    array (
      0 => 'Tue, 21 Jul 2020 14:33:11 GMT',
    ),
    'Server' => 
    array (
      0 => 'nginx/1.14.0 (Ubuntu)',
    ),
    'Content-Type' => 
    array (
      0 => 'application/json',
    ),
    'Vary' => 
    array (
      0 => 'Accept-Encoding,Accept-Language,Cookie',
    ),
    'Allow' => 
    array (
      0 => 'GET, HEAD, OPTIONS',
    ),
    'ETag' => 
    array (
      0 => 'W/"2020-07-21 11:09:52.985039+00:00"',
    ),
    'Content-Language' => 
    array (
      0 => 'en',
    ),
    'X-Frame-Options' => 
    array (
      0 => 'SAMEORIGIN',
    ),
    'Content-Security-Policy' => 
    array (
      0 => 'connect-src \'self\'; img-src *; style-src \'self\'; font-src \'self\'; script-src \'self\'; form-action \'self\'; default-src \'none\'',
    ),
    'X-Content-Type-Options' => 
    array (
      0 => 'nosniff',
    ),
    'X-XSS-Protection' => 
    array (
      0 => '1; mode=block',
    ),
    'X-Cache-Status' => 
    array (
      0 => 'HIT',
    ),
    'X-Cache-Date' => 
    array (
      0 => 'Tue, 21 Jul 2020 11:28:01 GMT',
    ),
    'Transfer-Encoding' => 
    array (
      0 => 'chunked',
    ),
    'x-encoded-content-encoding' => 
    array (
      0 => 'gzip',
    ),
  ),
   'headerNames' => 
  array (
    'date' => 'Date',
    'server' => 'Server',
    'content-type' => 'Content-Type',
    'vary' => 'Vary',
    'allow' => 'Allow',
    'etag' => 'ETag',
    'content-language' => 'Content-Language',
    'x-frame-options' => 'X-Frame-Options',
    'content-security-policy' => 'Content-Security-Policy',
    'x-content-type-options' => 'X-Content-Type-Options',
    'x-xss-protection' => 'X-XSS-Protection',
    'x-cache-status' => 'X-Cache-Status',
    'x-cache-date' => 'X-Cache-Date',
    'transfer-encoding' => 'Transfer-Encoding',
    'x-encoded-content-encoding' => 'x-encoded-content-encoding',
  ),
   'protocol' => '1.1',
   'stream' => 
  GuzzleHttp\Psr7\Stream::__set_state(array(
     'stream' => NULL,
     'size' => NULL,
     'seekable' => true,
     'readable' => true,
     'writable' => true,
     'uri' => 'php://temp',
     'customMetadata' => 
    array (
    ),
  )),
))

and:

$easy->errno is “23” …

If I insert and var_export() a curl_exec($easy->handle); right before the return in CurlFactory::create(), curl_exec() returns a false with the nextcloud cURL options:

        $easy->handle = $this->handles
            ? array_pop($this->handles)
            : curl_init();

        curl_setopt_array($easy->handle, $conf);

        var_export(curl_exec($easy->handle));
        die();

        return $easy;
    }

result: false


But if I use other cURL options like:

        $easy->handle = $this->handles
            ? array_pop($this->handles)
            : curl_init();

        // curl_setopt_array($easy->handle, $conf);

        curl_setopt($easy->handle, CURLOPT_URL, "http://www.github.com");
        curl_setopt($easy->handle, CURLOPT_HEADER, 0);
        var_export(curl_exec($easy->handle));
        die();

        return $easy;
    }

result: true


$conf:

array (
  10036 => 'GET',
  10002 => 'https://apps.nextcloud.com/api/v1/apps.json',
  19913 => false,
  42 => false,
  78 => 150,
  181 => 3,
  84 => 2,
  81 => 2,
  64 => true,
  10065 => '/www/nextcloud.domain.tld/data/files_external/rootcerts.crt',
  10102 => 'gzip',
  10001 => NULL,
  155 => 60000,
  10023 => 
  array (
    0 => 'Host: apps.nextcloud.com',
    1 => 'Accept-Encoding: gzip',
    2 => 'User-Agent: Nextcloud Server Crawler',
    3 => 'Accept:',
  ),
  20079 => 
  Closure::__set_state(array(
  )),
)

Any idea? :face_with_raised_eyebrow:

curl_errno() is 0
curl_error() is empty (empty string)


Guess I found someting! :wink:
Since I’ve manually set the $conf array for curl_setopt_array($easy->handle, $conf);, I could isolate the problem:

$conf = [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_URL => "https://apps.nextcloud.com/api/v1/apps.json",
    CURLOPT_RETURNTRANSFER => false,
    CURLE_ABORTED_BY_CALLBACK => false,
    CURLOPT_CONNECTTIMEOUT => 150,
    CURLOPT_PROTOCOLS => 3,
    CURLOPT_HTTP_VERSION => 2,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_CAINFO => '/www/nextcloud.domain.tld/data/files_external/rootcerts.crt',
//  CURLOPT_ENCODING => 'gzip',
//  CURLOPT_FILE => null,
//  CURLOPT_TIMEOUT_MS => 60000,
    /*CURLOPT_HTTPHEADER => [
        'Host: apps.nextcloud.com',
        'Accept-Encoding: gzip',
        'User-Agent: Nextcloud Server Crawler',
        'Accept:',
    ],*/
    //CURLOPT_HEADERFUNCTION => '?????'
];

result: CURLOPT_ENCODING => 'gzip' is the problem, but why? :face_with_raised_eyebrow:

Uninstall the existing cURL libraries / packages and install the official ones (from the ubuntu repositories).
Then restart php-fpm.