apache/pulsar · error · IllegalArgumentException
Invalid pulsar service : ${serviceName}+${serviceInfos}
Error message
Invalid pulsar service : ${serviceName}+${serviceInfos} What it means
For a BINARY ('pulsar') service, ServiceURI expects either no service-info suffix (plain, default binary port 6650) or exactly the single suffix 'ssl' (TLS binary port 6651). Any other combination of serviceInfos appended after '+' (e.g. 'pulsar+foo', 'pulsar+ssl+extra') is rejected with 'Invalid pulsar service : <serviceName>+<serviceInfos>'.
Source
Thrown at pulsar-common/src/main/java/org/apache/pulsar/common/net/ServiceURI.java:225
} else {
if (serviceInfos.length == 0) {
return serviceName;
} else {
return serviceName + "+" + StringUtils.join(serviceInfos, '+');
}
}
}
private static int getServicePort(String serviceName, String[] serviceInfos) {
int port;
switch (serviceName.toLowerCase()) {
case BINARY_SERVICE:
if (serviceInfos.length == 0) {
port = BINARY_PORT;
} else if (serviceInfos.length == 1 && serviceInfos[0].equalsIgnoreCase(SSL_SERVICE)) {
port = BINARY_TLS_PORT;
} else {
throw new IllegalArgumentException("Invalid pulsar service : " + serviceName + "+"
+ Arrays.toString(serviceInfos));
}
break;
case HTTP_SERVICE:
port = HTTP_PORT;
break;
case HTTPS_SERVICE:
port = HTTPS_PORT;
break;
default:
throw new IllegalArgumentException("Invalid pulsar service : " + serviceName);
}
return port;
}
/**
* Create a new URI from the service URI which only specifies one of the hosts.
* @return a pulsar service URI with a single host specifiedView on GitHub (pinned to 820761864e)
Solutions
- Use 'pulsar://host:6650' for plain binary or 'pulsar+ssl://host:6651' for TLS — no other suffixes are valid.
- If you meant TLS, replace '+tls' with '+ssl'.
- Remove extra '+'-separated segments from the URI scheme.
- Use 'http://' or 'https://' service URIs if you intended the HTTP service instead.
Example fix
// before
ServiceURI u = ServiceURI.create("pulsar+tls://broker:6651");
// after
ServiceURI u = ServiceURI.create("pulsar+ssl://broker:6651"); Defensive patterns
Strategy: validation
Validate before calling
static final Set<String> VALID_BINARY_INFOS = Set.of("ssl");
static void validateServiceUri(String scheme) {
String[] parts = scheme.split("\\+");
String service = parts[0];
String[] infos = Arrays.copyOfRange(parts, 1, parts.length);
if (List.of("pulsar","broker").contains(service)
&& !(infos.length == 0 || (infos.length == 1 && infos[0].equalsIgnoreCase("ssl")))) {
throw new IllegalArgumentException("Invalid pulsar service : " + scheme);
}
} Try / catch
try {
ServiceURI uri = ServiceURI.create(serviceUrl);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Invalid pulsar service")) {
// scheme suffix wrong: only pulsar:// or pulsar+ssl:// allowed for binary service
}
throw e;
} Prevention
- Only use the documented schemes: pulsar, pulsar+ssl, http, https, broker, broker+ssl.
- Never write '+tls' — the accepted suffix is '+ssl'.
- Keep exactly one '+'-separated info segment at most.
When it happens
Trigger: ServiceURI.create('pulsar+foo://host:6650') or 'pulsar+ssl+extra://...' — a service name that is 'pulsar'/'binary' combined with a serviceInfo other than 'ssl' (case-insensitive) or more than one info.
Common situations: Typos in the scheme such as 'pulsar+tls' (correct is 'pulsar+ssl'); accidentally duplicating the suffix ('pulsar+ssl+ssl'); copying an http-style URI scheme onto a binary port.
Related errors
- Invalid pulsar service : ${serviceName}
- Invalid hostname : ${hostname}
- host must not be null
- the value ${strUri} in the `advertisedListeners` configure i
- Invalid key format
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/d34a0a299e196f05.
Report an issue: GitHub.