apache/shenyu · error · ShenyuException

shenyu register into ShenyuDiscoveryService

Error message

shenyu register into ShenyuDiscoveryService %s type find error

What it means

InstanceRegisterListener.onApplicationEvent registers the client instance (host/port) into the configured ShenyuDiscoveryService (zookeeper, nacos, etcd...). Any exception thrown by the discovery provider's persistInstance (connection loss, unknown type, provider failure) is caught, logged, and rethrown as a ShenyuException naming the register type.

Solutions

  1. Read the chained cause in the log line `shenyu register into ShenyuDiscoveryService ... type find error` to see the root failure.
  2. Verify the registry address (`shenyu.discovery.serverList`) is reachable (telnet/nc the host:port) and credentials are correct.
  3. Confirm `shenyu.discovery.type` matches an available ShenyuDiscoveryService SPI implementation on the classpath.
  4. Retry startup once the registry is healthy; the registration is idempotent (persistInstance).

Example fix

# before (type with no provider on classpath)
shenyu:
  discovery:
    type: consul
# after (match an available SPI, e.g. zookeeper starter present)
shenyu:
  discovery:
    type: zookeeper
    serverList: localhost:2181
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: registry reachable?
try (Socket s = new Socket()) {
    s.connect(new InetSocketAddress(host, port), 3000); // throws if registry down
}

Try / catch

try {
    applicationEventPublisher.publishEvent(event);
} catch (ShenyuException e) {
    LOGGER.error("instance registration failed, will not retry automatically: {}", e.getMessage(), e);
    // alert / mark app unhealthy
}

Prevention

When it happens

Trigger: Application startup (ApplicationReadyEvent) when discoveryService.persistInstance fails: discovery server unreachable, wrong `shenyu.discovery.type` with no matching SPI implementation, invalid registerPath/props (e.g. missing `name`), or auth failure against the registry.

Common situations: Registry (zk/nacos/etcd) down or firewalled at dev startup; typo in discovery type so ExtensionLoader returns no implementation; registry credentials wrong; network partition in k8s between client pod and registry.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12). Data as JSON: /api/errors/daf86e5284c52a9b. Report an issue: GitHub.

Appendix: source

Thrown at shenyu-client/shenyu-client-core/src/main/java/org/apache/shenyu/client/core/register/InstanceRegisterListener.java:93

        try {
            if (StringUtils.isBlank(discoveryConfig.getRegisterType()) || StringUtils.equalsIgnoreCase(discoveryConfig.getRegisterType(), "local")) {
                return;
            }
            this.discoveryService = ExtensionLoader.getExtensionLoader(ShenyuInstanceRegisterRepository.class).getJoin(discoveryConfig.getRegisterType());
            discoveryConfig.getProps().put("watchPath", path);
            discoveryService.init(discoveryConfig);
            InstanceEntity instance = new InstanceEntity();
            instance.setStatus(currentInstanceUpstream.getStatus());
            instance.setWeight(currentInstanceUpstream.getWeight());
            final URI uri = URI.create(currentInstanceUpstream.getProtocol() + currentInstanceUpstream.getUrl());
            instance.setPort(uri.getPort());
            instance.setHost(uri.getHost());
            instance.setAppName(discoveryConfig.getProps().getProperty("name"));
            discoveryService.persistInstance(instance);
            LOGGER.info("shenyu register into ShenyuDiscoveryService {} success", discoveryConfig.getRegisterType());
        } catch (Exception e) {
            LOGGER.error("shenyu register into ShenyuDiscoveryService  {} type find error", discoveryConfig.getRegisterType(), e);
            throw new ShenyuException(String.format("shenyu register into ShenyuDiscoveryService %s type find error", discoveryConfig.getRegisterType()));
        }
    }

    @Override
    public int getOrder() {
        return HIGHEST_PRECEDENCE;
    }
}

View on GitHub (pinned to 567142e072)