google-cloud-java: DEADLINE_EXCEEDED when using Cloud Pub/Sub library from Compute Engine

When using the Cloud Pub/Sub library in a Java application that has been deployed in a Google Compute Engine instance, a DEADLINE_EXCEEDED exception occurs. The application resides in a Docker container within a Container Engine-managed Compute Engine instance. The Pub/Sub topic and the Compute Engine instance are in the same project.

The Compute Engine service account has project editor permissions.

No problems with the old google-api-services-pubsub library.

The code to create the instance looks like this:

InputStream credentialsStream = IOUtils.toInputStream(SERVICE_ACCOUNT_JSON, StandardCharsets.UTF_8);
Credentials credentials = ServiceAccountCredentials.fromStream(credentialsStream);
PubSubOptions options = PubSubOptions.newBuilder().setCredentials(credentials).build();
PubSub pubsub = options.getService();

Then doing something like this (or alternatively, create a topic):

for (Subscription subscription : pubsub.listSubscriptions().getValues()) {
...
}

results in the following:

com.google.cloud.pubsub.PubSubException: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED

Versions:

google-cloud-pubsub - v0.6.0
google-auth-library-oauth2-http - v0.6.0
google-auth-library-credentials - v0.6.0
google-* - v1.22.0

I also found this issue at Stackoverflow

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 36 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I am having this problem when running locally in my project. I’m using google-cloud version 0.8.0. I’ve tried the previous suggestions and nothing solved my problem. I’m still getting this exception:

java.util.concurrent.ExecutionException: com.google.cloud.pubsub.PubSubException: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED.

Does anyone have any similar problem?

+1. Same happening to me. Only fixed when I force netty-all version like recommended above.

		<dependency>
			<groupId>com.google.cloud</groupId>
			<artifactId>google-cloud</artifactId>
			<version>0.8.0</version>
		</dependency>
		<dependency>
			<groupId>io.netty</groupId>
			<artifactId>netty-all</artifactId>
			<version>4.1.3.Final</version>
		</dependency>