Troubleshooting

Stay organized with collections Save and categorize content based on your preferences.

Tracing GRPC issues

Before you begin

Be sure to initialize and enable write permissions before writing to your log file. In the following example, the log file is named /var/log/grpc.log:

touch /var/log/grpc.log
chmod 666 /var/log/grpc.log

If you encounter file permissions issues, you might need to preface the previous commands with sudo.

Logging to a file

To save gRPC logs to a file, add the following lines to your php.ini file:

grpc.grpc_verbosity=debug
grpc.grpc_trace=all,-timer_check
grpc.log_filename=/var/log/grpc.log

To write logs to stderr instead, exclude the last line from the previous example. For more information about other options, see gRPC environment variables.

Error Details

Google Cloud services follow AIP-193 guidelines when returning errors. Google Cloud services use a defined set of standard error payloads, which you can find in google.rpc.error_details.proto. These cover the most common API errors, such as quota failure and invalid parameters.

API errors emitted by PHP client libraries contain message, code, status, and details fields. Within the details field, additional google.rpc.ErrorInfo data appears in reason, domain, and metadata fields. The following sample shows an error that might appear if you called the Translation library with a cloud project before enabling the Translate API:

Google\ApiCore\ApiException: {
    "reason": "SERVICE_DISABLED",
    "domain": "googleapis.com",
    "errorInfoMetadata": {
        "consumer": "projects\PROJECT_ID",
        "service": "translate.googleapis.com"
    },
    "message": "Cloud Translation API has not been used in project PROJECT_ID before or it is disabled. Enable it by visiting https:\/\/console.developers.google.com\/apis\/api\/translate.googleapis.com\/overview?project=PROJECT_ID then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "code": 7,
    "status": "PERMISSION_DENIED",
    "details": [
        {
            "@type": "google.rpc.errorinfo-bin",
            "reason": "SERVICE_DISABLED",
            "domain": "googleapis.com",
            "metadata": {
                "consumer": "projects\PROJECT_ID",
                "service": "translate.googleapis.com"
            }
        },
        {
            "@type": "google.rpc.help-bin",
            "links": [
                {
                    "description": "Google developers console API activation",
                    "url": "https:\/\/console.developers.google.com\/apis\/api\/translate.googleapis.com\/overview?project=PROJECT_ID"
                }
            ]
        }
    ]
}

For more information about the general error model for Google APIs, see Cloud API Errors.