{"record":{"id":"5b2b349cc219c40d","repo":"aeron-io/aeron","slug":"endpoint-has-port-0-for-send-destination-channel","errorCode":null,"errorMessage":"endpoint has port=0 for send destination: channel={destinationUri}","messagePattern":"endpoint has port=0 for send destination: channel=(.+?)","errorType":"validation","errorClass":"InvalidChannelException","httpStatus":null,"severity":"error","filePath":"aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java","lineNumber":2401,"sourceCode":"                throw new InvalidChannelException(\n                    \"destinations must not contain the key: \" + invalidKey + \" channel=\" + destinationUri);\n            }\n        }\n\n        if (Objects.equals(CONTROL_MODE_RESPONSE, uri.get(MDC_CONTROL_MODE_PARAM_NAME)))\n        {\n            throw new InvalidChannelException(\"destinations may not specify \" +\n                MDC_CONTROL_MODE_PARAM_NAME + \"=\" + CONTROL_MODE_RESPONSE);\n        }\n    }\n\n    private static void validateSendDestinationUri(final ChannelUri uri, final String destinationUri)\n    {\n        final String endpoint = uri.get(ENDPOINT_PARAM_NAME);\n\n        if (null != endpoint && endpoint.endsWith(\":0\"))\n        {\n            throw new InvalidChannelException(ENDPOINT_PARAM_NAME + \" has port=0 for send destination: channel=\" +\n                destinationUri);\n        }\n    }\n\n    @SuppressWarnings({ \"unused\", \"UnnecessaryReturnStatement\" })\n    private static void validateExperimentalFeatures(final boolean enableExperimentalFeatures, final UdpChannel channel)\n    {\n        if (enableExperimentalFeatures)\n        {\n            return;\n        }\n\n        /*\n         * Put experimental feature validation here.\n         */\n    }\n\n    static FeedbackDelayGenerator resolveDelayGenerator(","sourceCodeStart":2383,"sourceCodeEnd":2419,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java#L2383-L2419","documentation":"A send destination URI includes an endpoint parameter ending in \":0\", i.e. an explicitly requested port 0. Port 0 (ephemeral) is not meaningful for a send destination because the driver must send data to a concrete remote port; the driver throws InvalidChannelException.","triggerScenarios":"Calling Publication.addDestination() or creating an MDC send channel with a destination like \"aeron:udp?endpoint=host:0\".","commonSituations":"Unfilled port placeholders in generated configs; copying a bind-endpoint (where port 0 can request an ephemeral local port) into an endpoint used as a send target; typos like \":O\" avoided but \":0\" kept.","solutions":["Set a concrete remote port in the destination endpoint (e.g. endpoint=host:40456).","If a dynamic local port is needed, use the interface/endpoints parameter for binding, not the send endpoint.","Add pre-call validation: reject destination URIs whose endpoint ends with \":0\"."],"exampleFix":"// before\npublication.addDestination(\"aeron:udp?endpoint=host:0\");\n// after\npublication.addDestination(\"aeron:udp?endpoint=host:40456\");","handlingStrategy":"validation","validationCode":"ChannelUri uri = ChannelUri.parse(destination);\nString endpoint = uri.get(\"endpoint\");\nif (endpoint != null && endpoint.endsWith(\":0\")) throw new IllegalArgumentException(\"send destination endpoint needs a concrete port\");","typeGuard":"boolean hasConcreteSendPort(ChannelUri uri) {\n  String ep = uri.get(\"endpoint\");\n  return ep == null || !ep.endsWith(\":0\");\n}","tryCatchPattern":"try { publication.addDestination(destination); }\ncatch (InvalidChannelException e) { if (e.getMessage().contains(\"has port=0 for send destination\")) { /* set a real port */ } else throw e; }","preventionTips":["Reject \":0\" endpoints in destination template rendering","Differentiate bind endpoints (port 0 allowed) from send endpoints (not allowed)","Store remote ports in config with explicit defaults"],"tags":["aeron","destination-uri","port","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}