apache/seatunnel · critical · GooglePubSubConnectorException

CONNECTION_FAILED

CONNECTION_FAILED

Error message

Failed to create Google Pub/Sub subscriber for subscription ${subscription}

What it means

GooglePubSubSubscriber.create builds a com.google.cloud.pubsub.v1.Subscriber for the configured subscription; if construction fails for any reason the exception is wrapped in GooglePubSubConnectorException(CONNECTION_FAILED) and the emulator channel (if used) is shut down. It means the subscriber client could not be created at all, before any pull was attempted.

Source

Thrown at seatunnel-connectors-v2/connector-google-pubsub/src/main/java/org/apache/seatunnel/connectors/seatunnel/google/pubsub/source/GooglePubSubSubscriber.java:107

                                                            .getDefaultServiceScopes())));
                }
            }

            Subscriber subscriber = subscriberBuilder.build();
            subscriber.addListener(
                    new ApiService.Listener() {
                        @Override
                        public void failed(ApiService.State from, Throwable failure) {
                            failureHandler.accept(failure);
                        }
                    },
                    Runnable::run);
            return new GooglePubSubSubscriber(subscriber, emulatorChannel);
        } catch (Exception e) {
            if (emulatorChannel != null) {
                emulatorChannel.shutdownNow();
            }
            throw new GooglePubSubConnectorException(
                    GooglePubSubConnectorErrorCode.CONNECTION_FAILED,
                    "Failed to create Google Pub/Sub subscriber for subscription "
                            + config.getSubscription(),
                    e);
        }
    }

    private static void configureFlowControl(
            Subscriber.Builder subscriberBuilder, GooglePubSubSourceConfig config) {
        if (config.getMaxOutstandingMessages() != null || config.getMaxOutstandingBytes() != null) {
            FlowControlSettings.Builder flowControlSettings =
                    Subscriber.Builder.getDefaultFlowControlSettings().toBuilder();
            if (config.getMaxOutstandingMessages() != null) {
                flowControlSettings.setMaxOutstandingElementCount(
                        config.getMaxOutstandingMessages());
            }
            if (config.getMaxOutstandingBytes() != null) {
                flowControlSettings.setMaxOutstandingRequestBytes(config.getMaxOutstandingBytes());

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Verify the cause: hostname resolution, credentials, or subscription path
  2. Confirm subscription exists: gcloud pubsub subscriptions describe <name>
  3. Set GOOGLE_APPLICATION_CREDENTIALS to a valid service-account JSON with pubsub.subscriber role
  4. If using the emulator, check PUBSUB_EMULATOR_HOST is reachable
  5. Enable the Cloud Pub/Sub API on the project

Example fix

// before
subscription = "my-sub"
// after
subscription = "projects/my-project/subscriptions/my-sub"
Defensive patterns

Strategy: validation

Validate before calling

gcloud pubsub subscriptions describe projects/my-project/subscriptions/my-sub  # run before job
gcloud auth application-default print-access-token   # verify credentials

Try / catch

try { GooglePubSubSubscriber.create(config); } catch (GooglePubSubConnectorException e) { log.error("subscriber create failed: {}", e.getCause()); throw e; }

Prevention

When it happens

Trigger: Subscriber.newBuilder(...).build() throws — unresolvable host, invalid subscription project path, invalid credentials, or emulator channel setup failure when the emulator is configured.

Common situations: Wrong project id or subscription name in HOCON config; missing GOOGLE_APPLICATION_CREDENTIALS; offline/air-gapped environment; malformed emulator host; missing pubsub API enabled on the project.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/45b8847a11557399. Report an issue: GitHub.