google-cloud-php: google/cloud-pubsub cURL error 35 gnutls_handshake

The package google/cloud-core, which is used by google/cloud-pubsub, is throwing the exception referenced below from time to time.

I’m using a PHP flex environment:

  • PHP 7.2.18
  • curl 7.52.1
exception:  "Google\Cloud\Core\Exception\ServiceException: cURL error 35: gnutls_handshake() failed: The TLS connection was non-properly terminated. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in /app/symfony/vendor/google/cloud-core/src/RequestWrapper.php:263
Stack trace:
#0 /app/symfony/vendor/google/cloud-core/src/RequestWrapper.php(168): Google\Cloud\Core\RequestWrapper->convertToGoogleException(Object(GuzzleHttp\Exception\ConnectException))
#1 /app/symfony/vendor/google/cloud-core/src/RestTrait.php(95): Google\Cloud\Core\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request), Array)
#2 /app/symfony/vendor/google/cloud-logging/src/Connection/Rest.php(60): Google\Cloud\Logging\Connection\Rest->send('entries', 'write', Array)
#3 /app/symfony/vendor/google/cloud-logging/src/Logger.php(389): Google\Cloud\Logging\Connection\Rest->writeEntries(Array)
#4 /app/symfony/vendor/google/cloud-logging/src/Logger.php(358): Google\Cloud\Logging\Logger->writeBatch(Array, Array)
#5 /app/symfony/vendor/google/cloud-logging/src/PsrLogger.php(528): Google\Cloud\Logging\Logger->write(Object(Google\Cloud\Logging\Entry))
#6 /app/symfony/vendor/google/cloud-logging/src/PsrLogger.php(413): Google\Cloud\Logging\PsrLogger->sendEntry(Object(Google\Cloud\Logging\Entry))
#7 /app/symfony/src/Services/StackDriverHandler.php(58): Google\Cloud\Logging\PsrLogger->log('critical', 'Uncaught PHP Ex...', Array)
#8 /app/symfony/vendor/monolog/monolog/src/Monolog/Logger.php(337): App\Services\StackDriverHandler->handle(Array)
#9 /app/symfony/vendor/monolog/monolog/src/Monolog/Logger.php(644): Monolog\Logger->addRecord(500, 'Uncaught PHP Ex...', Array)
#10 /app/symfony/vendor/symfony/http-kernel/EventListener/ExceptionListener.php(108): Monolog\Logger->critical('Uncaught PHP Ex...', Array)
#11 /app/symfony/vendor/symfony/http-kernel/EventListener/ExceptionListener.php(48): Symfony\Component\HttpKernel\EventListener\ExceptionListener->logException(Object(Google\Cloud\Core\Exception\ServiceException), 'Uncaught PHP Ex...')
#12 /app/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php(212): Symfony\Component\HttpKernel\EventListener\ExceptionListener->logKernelException(Object(Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent), 'kernel.exceptio...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#13 /app/symfony/vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'kernel.exceptio...', Object(Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent))
#14 /app/symfony/vendor/symfony/http-kernel/HttpKernel.php(219): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('kernel.exceptio...', Object(Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent))
#15 /app/symfony/vendor/symfony/http-kernel/HttpKernel.php(77): Symfony\Component\HttpKernel\HttpKernel->handleException(Object(Google\Cloud\Core\Exception\ServiceException), Object(Symfony\Component\HttpFoundation\Request), 1)
#16 /app/symfony/vendor/symfony/http-kernel/Kernel.php(188): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /app/symfony/public/index.php(34): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#18 {main}" 

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Having this issue myself, for quite some time, but it’s starting to get extremely annoying.

I’m on App Engine Flex PHP 7.3 (pretty much the official Google App Engine PHP Docker image…)

We have a Laravel Artisan command that runs once a day (at around 3am) and stores several files on Google Storage, therefore it performs several uploads, around 500, more or less.

The uploaded files are not that big, are gzipped and are on average around 5kb.

Noticed that while this still happens during the week, is not every single day and can go the entire week without problems sometimes, but during the weekends, it usually fails, a lot.

Here’s the stack (similar as above)

Google\Cloud\Core\Exception\ServiceException cURL error 35: gnutls_handshake() failed: An unexpected TLS packet was received. (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) 
    vendor/google/cloud-core/src/RequestWrapper.php:368 Google\Cloud\Core\RequestWrapper::convertToGoogleException
    vendor/google/cloud-core/src/RequestWrapper.php:207 Google\Cloud\Core\RequestWrapper::send
    vendor/google/cloud-core/src/RestTrait.php:97 Google\Cloud\Storage\Connection\Rest::send
    vendor/google/cloud-storage/src/Connection/Rest.php:224 Google\Cloud\Storage\Connection\Rest::getObject
    vendor/google/cloud-storage/src/StorageObject.php:147 Google\Cloud\Storage\StorageObject::exists
    vendor/superbalist/flysystem-google-storage/src/GoogleStorageAdapter.php:326 Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter::has
    vendor/league/flysystem/src/Filesystem.php:57 League\Flysystem\Filesystem::has
    vendor/league/flysystem/src/Filesystem.php:98 League\Flysystem\Filesystem::put
    vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php:231 Illuminate\Filesystem\FilesystemAdapter::put
    app/Jobs/DailyEmail/CacheMentions.php:96 App\Jobs\DailyEmail\CacheMentions::handle
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
    vendor/laravel/framework/src/Illuminate/Container/Util.php:37 Illuminate\Container\Util::unwrapIfClosure
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93 Illuminate\Container\BoundMethod::callBoundMethod
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 Illuminate\Container\BoundMethod::call
    vendor/laravel/framework/src/Illuminate/Container/Container.php:596 Illuminate\Container\Container::call
    vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:94 Illuminate\Bus\Dispatcher::Illuminate\Bus\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103 Illuminate\Pipeline\Pipeline::then
    vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:98 Illuminate\Bus\Dispatcher::dispatchNow
    vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php:53 App\Jobs\AbstractJob::dispatchNow
    app/Jobs/DailyEmail/SendDailyEmail.php:146 App\Jobs\DailyEmail\SendDailyEmail::getDataFromStorage
    app/Jobs/DailyEmail/SendDailyEmail.php:160 App\Jobs\DailyEmail\SendDailyEmail::getData
    app/Jobs/DailyEmail/SendDailyEmail.php:73 App\Jobs\DailyEmail\SendDailyEmail::App\Jobs\DailyEmail\{closure}
    [internal] array_map
    vendor/laravel/framework/src/Illuminate/Support/Collection.php:638 Illuminate\Support\Collection::map
    vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php:276 Illuminate\Database\Eloquent\Collection::map
    app/Jobs/DailyEmail/SendDailyEmail.php:93 App\Jobs\DailyEmail\SendDailyEmail::handle
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
    vendor/laravel/framework/src/Illuminate/Container/Util.php:37 Illuminate\Container\Util::unwrapIfClosure
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93 Illuminate\Container\BoundMethod::callBoundMethod
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 Illuminate\Container\BoundMethod::call
    vendor/laravel/framework/src/Illuminate/Container/Container.php:596 Illuminate\Container\Container::call
    vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:94 Illuminate\Bus\Dispatcher::Illuminate\Bus\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103 Illuminate\Pipeline\Pipeline::then
    vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:98 Illuminate\Bus\Dispatcher::dispatchNow
    vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:83 Illuminate\Queue\CallQueuedHandler::Illuminate\Queue\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103 Illuminate\Pipeline\Pipeline::then
    vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:85 Illuminate\Queue\CallQueuedHandler::dispatchThroughMiddleware
    vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:59 Illuminate\Queue\CallQueuedHandler::call
    vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:98 Illuminate\Queue\Jobs\Job::fire
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:356 Illuminate\Queue\Worker::process
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:306 Illuminate\Queue\Worker::runJob
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:132 Illuminate\Queue\Worker::daemon
    vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:112 Illuminate\Queue\Console\WorkCommand::runWorker
    vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:96 Illuminate\Queue\Console\WorkCommand::handle
    vendor/laravel/horizon/src/Console/WorkCommand.php:46 Laravel\Horizon\Console\WorkCommand::handle
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
    vendor/laravel/framework/src/Illuminate/Container/Util.php:37 Illuminate\Container\Util::unwrapIfClosure
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93 Illuminate\Container\BoundMethod::callBoundMethod
    vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37 Illuminate\Container\BoundMethod::call
    vendor/laravel/framework/src/Illuminate/Container/Container.php:596 Illuminate\Container\Container::call
    vendor/laravel/framework/src/Illuminate/Console/Command.php:134 Illuminate\Console\Command::execute
    vendor/symfony/console/Command/Command.php:258 Symfony\Component\Console\Command\Command::run
    vendor/laravel/framework/src/Illuminate/Console/Command.php:121 Illuminate\Console\Command::run
    vendor/symfony/console/Application.php:920 Symfony\Component\Console\Application::doRunCommand
    vendor/symfony/console/Application.php:266 Symfony\Component\Console\Application::doRun
    vendor/symfony/console/Application.php:142 Symfony\Component\Console\Application::run
    vendor/laravel/framework/src/Illuminate/Console/Application.php:93 Illuminate\Console\Application::run
    vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129 Illuminate\Foundation\Console\Kernel::handle
    artisan:37 [main]

Anything i can help to identify the culprit of this? It seems to be caused only (as far as i can tell) for the PHP libraries, the Java one for example, seems to works as expected without major disruptions.

@meredithslota I personally do not have this issue anymore 😃

Should be OpenSSL, but i’ve not manually compiled it though, just installed both curl and then the php extension and that’s it.