{"record":{"id":"96165eca488f80a7","repo":"apache/shenyu","slug":"shenyu-tcpproxy-don-t-have-any-upstream","errorCode":null,"errorMessage":"shenyu TcpProxy don't have any upstream","messagePattern":"shenyu TcpProxy don't have any upstream","errorType":"exception","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/DefaultConnectionConfigProvider.java","lineNumber":64,"sourceCode":"    private final String pluginSelectorName;\n\n    public DefaultConnectionConfigProvider(final String loadBalanceAlgorithm, final String pluginSelectorName) {\n        this.loadBalanceAlgorithm = loadBalanceAlgorithm;\n        this.pluginSelectorName = pluginSelectorName;\n    }\n\n    @Override\n    public URI getProxiedService(final String ip) {\n        List<Upstream> upstreamList = UpstreamProvider.getSingleton().provide(this.pluginSelectorName).stream().map(dp -> Upstream.builder()\n                .url(dp.getUrl())\n                .status(open(dp.getStatus()))\n                .weight(dp.getWeight())\n                .protocol(dp.getProtocol())\n                .warmup(JsonUtils.jsonToMap(dp.getProps(), Integer.class).get(\"warmupTime\"))\n                .timestamp(dp.getDateCreated().getTime())\n                .build()).collect(Collectors.toList());\n        if (CollectionUtils.isEmpty(upstreamList)) {\n            throw new ShenyuException(\"shenyu TcpProxy don't have any upstream\");\n        }\n        LoadBalanceData data = new LoadBalanceData();\n        data.setIp(ip);\n        Upstream upstream = LoadBalancerFactory.selector(upstreamList, loadBalanceAlgorithm, data);\n        return cover(upstream);\n    }\n\n    private URI cover(final Upstream upstream) {\n        try {\n            return new URI(upstream.getProtocol() + \"://\" + upstream.getUrl());\n        } catch (URISyntaxException e) {\n            LOG.error(\"Upstream url is wrong\", e);\n            throw new ShenyuException(e);\n        }\n    }\n\n    /**\n     * false close, true open.","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-protocol/shenyu-protocol-tcp/src/main/java/org/apache/shenyu/protocol/tcp/connection/DefaultConnectionConfigProvider.java#L46-L82","documentation":"DefaultConnectionConfigProvider.getProxiedService builds the upstream list from the discovered DivideUpstream entries for a TCP proxy service; if the list is empty it means no healthy upstream instances exist for the requested backend, so selecting a target via the load balancer is impossible and a ShenyuException is thrown.","triggerScenarios":"Calling getProxiedService (via TcpProxy connection setup) when no upstream was registered for the service name, all upstreams were pruned as unhealthy/removed, or data-sync has not yet delivered the selector/upstream data to the gateway.","commonSituations":"Backend TCP service not started or not registered with admin; wrong service/selector name in the TCP request; gateway started before admin finished publishing config; all backend instances down so health checks removed them.","solutions":["Start/register the backend TCP service so upstreams appear in admin and sync to the gateway","Verify the service name and selector configuration in the shenyu-admin dashboard match what the TcpProxy request uses","Check gateway data-sync connectivity (websocket/http) so upstream data is actually delivered","Confirm backend instance health-check status; re-add healthy instances"],"exampleFix":"// before\ncurl-like tcp request to a service with zero registered upstreams\n// after\nregister the backend and confirm instances are visible in shenyu-admin before proxying","handlingStrategy":"validation","validationCode":"List<DivideUpstream> upstreams = ...; if (upstreams == null || upstreams.isEmpty()) { failFast(\"no upstream registered for tcp service\"); }","typeGuard":null,"tryCatchPattern":"try { service = provider.getProxiedService(...); } catch (ShenyuException e) { log.warn(\"no tcp upstream: {}\", e.getMessage()); return fallbackResponse(); }","preventionTips":["Confirm the backend registers before the gateway proxies traffic","Monitor upstream list size for the selector and alert on zero","Verify data-sync channel health so upstream data reaches the gateway"],"tags":["gateway","tcp-proxy","loadbalancer","upstream"],"backgroundTag":"empty-result-set","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}