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
- Verify the cause: hostname resolution, credentials, or subscription path
- Confirm subscription exists: gcloud pubsub subscriptions describe <name>
- Set GOOGLE_APPLICATION_CREDENTIALS to a valid service-account JSON with pubsub.subscriber role
- If using the emulator, check PUBSUB_EMULATOR_HOST is reachable
- 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
- Validate subscription path format projects/<proj>/subscriptions/<name> before submit
- Set GOOGLE_APPLICATION_CREDENTIALS and test with gcloud first
- Enable the Pub/Sub API on the project
- If using emulator, ping the emulator host first
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
- CONNECTION_FAILED
- Options 'credentials_path' and 'emulator_host' cannot be con
- Option 'field_delimiter' cannot be empty
- Option '${option}' cannot be blank
- Options 'credentials_path' and 'emulator_host' cannot be con
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/45b8847a11557399.
Report an issue: GitHub.