{"record":{"id":"97342754f1b15a1c","repo":"aeron-io/aeron","slug":"endpoint-param-name-has-port-0-for-publication-channel","errorCode":null,"errorMessage":"${ENDPOINT_PARAM_NAME} has port=0 for publication: channel=${originalUriString}","messagePattern":"(.+?) has port=0 for publication: channel=(.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java","lineNumber":2328,"sourceCode":"        final int existingLength,\n        final String channel,\n        final String existingChannel)\n    {\n        if (0 != newLength && newLength != existingLength)\n        {\n            final Object existingValue = 0 == existingLength ? \"OS default\" : existingLength;\n            throw new InvalidChannelException(\n                paramName + \"=\" + newLength + \" does not match existing value of \" + existingValue +\n                    \": existingChannel=\" + existingChannel + \" channel=\" + channel);\n        }\n    }\n\n    private static void validateEndpointForPublication(final UdpChannel udpChannel)\n    {\n        if (!udpChannel.isMultiDestination() && udpChannel.hasExplicitEndpoint() &&\n            0 == udpChannel.remoteData().getPort())\n        {\n            throw new IllegalArgumentException(\n                ENDPOINT_PARAM_NAME + \" has port=0 for publication: channel=\" + udpChannel.originalUriString());\n        }\n    }\n\n    private static void validateControlForPublication(final UdpChannel udpChannel)\n    {\n        if (udpChannel.isDynamicControlMode() && !udpChannel.hasExplicitControl())\n        {\n            throw new IllegalArgumentException(\n                \"'control-mode=dynamic' requires that 'control' parameter is set, channel=\" +\n                    udpChannel.originalUriString());\n        }\n\n        if (udpChannel.hasExplicitControl() && !udpChannel.hasExplicitEndpoint() &&\n            ControlMode.NONE == udpChannel.controlMode())\n        {\n            throw new IllegalArgumentException(\n                \"'control' parameter requires that either 'endpoint' or 'control-mode' is specified, channel=\" +","sourceCodeStart":2310,"sourceCodeEnd":2346,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java#L2310-L2346","documentation":"For publications, the 'endpoint' parameter must include a non-zero port: port 0 is only valid for the OS to pick a port on a server-side bind, which makes no sense for a data destination. The driver throws this IllegalArgumentException during channel validation when a non-multi-destination publication specifies an endpoint with port 0.","triggerScenarios":"Aeron.addPublication with \"aeron:udp?endpoint=host:0\" (or an omitted port parsing to 0) on a non-MDC publication; programmatically built URIs where the port variable defaulted to 0.","commonSituations":"Placeholder port not filled in from config; missing-env-var style bug where port config is absent and defaults to 0; mistaking subscription-style wildcard port usage as valid for publications.","solutions":["Set an explicit non-zero port in endpoint=host:port","Fix configuration so the port value is populated before constructing the URI","Validate the URI client-side before calling addPublication"],"exampleFix":"// before\naeron.addPublication(\"aeron:udp?endpoint=localhost:0\", 1001);\n// after\naeron.addPublication(\"aeron:udp?endpoint=localhost:40456\", 1001);","handlingStrategy":"validation","validationCode":"int port = uriEndpointPort(channel);\nif (port == 0) throw new IllegalArgumentException(\"publication endpoint port must be non-zero: \" + channel);","typeGuard":null,"tryCatchPattern":"try { aeron.addPublication(channel, streamId); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"has port=0\")) { log.error(\"fix endpoint port in {}\", channel); } throw e; }","preventionTips":["Fail fast on port==0 in URI-building code for publications","Validate config-provided ports are in 1..65535 at startup","Never reuse subscription-style wildcard port patterns for publications"],"tags":["aeron","uri","endpoint","port"],"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"}