1
votes

We have been getting these exceptions from Google this evening:

Google\Cloud\Core\Exception\ServiceException: cURL error 56: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Google\Cloud\Core\Exception\ServiceException(code: 0): cURL error 7: Failed to connect to oauth2.googleapis.com port 443: Connection timed out (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

Google\Cloud\Core\Exception\ServiceException(code: 0): cURL error 28: Operation timed out after 2001 milliseconds with 0 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

We can handle the exceptions fine, but there is a significant timeout between the connection initiation and the exception occurring. This means our server hangs for a long period of time as a request is initiated to Google, waits for connection to be properly created, fails, and then continues. This means our requests take a ridiculous amount of time (~20 seconds - 3 minutes approximately) instead of milliseconds.

So:

  • How can we determine what the root cause of this problem is? I'm assuming it's a Google related service issue, but their Google Console is clear
  • How can we set a timeout to be significantly shorter so that it doesn't cause long delays, particularly of importance with user facing requests.

We're using the PHP PubSubClient, specifically only the publish method at the moment.

1
Can you take a look at this (cloud.google.com/pubsub/docs/publisher#batching) and see if it helps you? - rmesteves
We're not batching our calls - we're only calling once per request. That does lead me to the API Reference Docs though (googleapis.github.io/google-cloud-php/#/docs/google-cloud/…), and in turn to github.com/googleapis/google-cloud-php/blob/v0.130.0/PubSub/src/… which defines a requestTimeout. But it says the default is 0 for REST... so why are we hanging still? - edhgoose

1 Answers

0
votes

I believe this can be fixed by the following:

$pubsub->publish(
    [
        'data'       => $data,
        'attributes' => $attributes,
    ],
    [

        'requestTimeout' => 2 // Set your own value here (in seconds)
    ]
);

This seems to be translated into a Guzzle option under the hood.

See \Google\Cloud\Core\RestTrait::send for more info