Learn about troubleshooting steps that you might find helpful if you run into problems using Cloud Pub/Sub.

Cannot create a subscription

Check that you have done all of the following:

  • Specified a subscription name in the name field. For version v1beta2 and above, the subscription name must be in the form projects/project-identifier/subscriptions/subscription-name.
  • Specified the name of an existing topic to which you want to subscribe, in the topic field. For version v1beta2 and above, the topic name must be in the form projects/project-identifier/topics/topic-name.
  • Specified https://, in lower case, not http:// or HTTPS:// as the protocol for your receiving URL in the pushEndpoint field.

Push subscriber not receiving any messages

Check the following:

  • Look in Stackdriver Monitoring for errors related to the subscription in question.
  • On App Engine, we recommend that you use the /_ah/push-handlers/ prefix in the endpoints URL path, as described in Registering App Engine endpoints. This allows the endpoint to receive push messages from Cloud Pub/Sub API.
  • In other environments, make sure that your endpoint URL can be accessed from the Internet without requiring sign-in. You can check that the URL is not restricted by accessing it with a diagnostic tool such as cURL.
  • For domains other than, make sure to register the domain in the Google Cloud Platform Console. See Registering other endpoints for details.

403 (Forbidden) error

If you get this error, do the following:

  • Make sure you've enabled the Cloud Pub/Sub API in the GCP Console.
  • Make sure that the principal making the request has the required permissions on the relevant Cloud Pub/Sub API resources, especially if you are using Cloud Pub/Sub API for cross-project communication.
  • If you're using Cloud Dataflow, make sure that both <projectId> and the Compute Engine Service account <projectId> have the required permissions on the relevant Cloud Pub/Sub API resource. See Google Cloud Dataflow Security and Permissions for more information.
  • If you're using App Engine, check your project's Permissions page to see if an App Engine Service Account is listed as an Editor. If it is not, add your App Engine Service Account as an Editor. Normally, the App Engine Service Account is of the form <project-id>

Dealing with duplicate messages

Cloud Pub/Sub can send duplicate messages. For instance, when you do not acknowledge a message before its acknowledgement deadline has expired, Cloud Pub/Sub resends the message. Use Stackdriver to monitor acknowledge operations with the expired response code to detect this condition. One way to get this data is the Acknowledge message operations metric, grouped by response_code.

Use Stackdriver to to search for expired message acknowledgement deadlines

To reduce the duplication rate, extend the message deadline:

  • Client libraries handle deadline extension automatically, but you should note that there are default limits on the maximum extension deadline that can be configured.
  • If you are building your own client library, use the modifyAckDeadline method to extend the acknowledgement deadline.

Using excessive administrative operations

If you find that you're using up too much of your quota for administrative operations, you might need to refactor your code. As an illustration, consider this pseudo-code. In this example, an administrative operation (GET) is being used to check for the presence of a subscription prior to an attempt to consume its resources. Note that both GET and CREATE are admin operations:

    if !GetSubscription my-sub {
     CreateSubscription my-sub
    Consume from subscription my-sub

A more efficient pattern is to try to consume messages from the subscription (assuming that you can be reasonably sure of the subscription's name). In this optimistic approach, you only get or create the subscription in the event of an error. Consider this example:

    try {
      Consume from subscription my-sub
    } catch NotFoundError {
      CreateSubscription my-sub
      Consume from subscription my-sub
¿Te ha resultado útil esta página? Enviar comentarios:

Enviar comentarios sobre...

Cloud Pub/Sub Documentation