{"record":{"id":"095c9ef003b9cd35","repo":"aeron-io/aeron","slug":"resource-temporarily-unavailable","errorCode":"RESOURCE_TEMPORARILY_UNAVAILABLE","errorMessage":"SendChannelEndpoint found in CLOSING state, please retry","messagePattern":"SendChannelEndpoint found in CLOSING state, please retry","errorType":"error_code","errorClass":"ControlProtocolException","httpStatus":null,"severity":"warning","filePath":"aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java","lineNumber":2486,"sourceCode":"        {\n        }\n    }\n\n    private abstract static class ClientCommand extends Command\n    {\n        final long correlationId;\n\n        private ClientCommand(final long correlationId)\n        {\n            this.correlationId = correlationId;\n        }\n    }\n\n    private static void throwResourceTemporaryUnavailableIfEndpointIsClosing(final SendChannelEndpoint endpoint)\n    {\n        if (ChannelEndpointStatus.CLOSING == endpoint.status())\n        {\n            throw new ControlProtocolException(\n                RESOURCE_TEMPORARILY_UNAVAILABLE,\n                \"SendChannelEndpoint found in CLOSING state, please retry\");\n        }\n    }\n\n    private static void throwResourceTemporaryUnavailableIfEndpointIsClosing(final ReceiveChannelEndpoint endpoint)\n    {\n        if (ChannelEndpointStatus.CLOSING == endpoint.status())\n        {\n            throw new ControlProtocolException(\n                RESOURCE_TEMPORARILY_UNAVAILABLE,\n                \"ReceiveChannelEndpoint found in CLOSING state, please retry\");\n        }\n    }\n\n    private final class AddNetworkPublicationCommand extends ClientCommand\n    {\n        private final String channel;","sourceCodeStart":2468,"sourceCodeEnd":2504,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-driver/src/main/java/io/aeron/driver/DriverConductor.java#L2468-L2504","documentation":"While adding a network publication the driver found the existing SendChannelEndpoint for the same channel in the CLOSING state. Because the endpoint is being torn down concurrently, the request cannot be processed now; the driver throws a ControlProtocolException with code RESOURCE_TEMPORARILY_UNAVAILABLE, telling the client the operation succeeded but must be retried shortly.","triggerScenarios":"Rapidly closing and immediately re-adding a publication on the same channel URI (e.g. close(oldPub); addPublication(sameUri)) while the driver conductor is still closing the old endpoint.","commonSituations":"Reconnect/retry loops that churn publications; test suites that recreate publications quickly; failover logic recreating senders after connection loss.","solutions":["Retry the addPublication()/channel setup after a short backoff until the endpoint finishes closing.","Treat error code RESOURCE_TEMPORARILY_UNAVAILABLE as retryable in your Aeron exception handler.","Avoid close-then-immediately-reopen on the same channel URI; reuse the existing publication where possible.","Poll the publication/endpoint status before re-adding on the same URI."],"exampleFix":"// before\npublication.close();\nPublication p = aeron.addPublication(sameUri, streamId); // may hit CLOSING\n// after\npublication.close();\nRetry: while (true) {\n  try { Publication p = aeron.addPublication(sameUri, streamId); break Retry; }\n  catch (ControlProtocolException e) { if (e.errorCode() != RESOURCE_TEMPORARILY_UNAVAILABLE) throw e; Thread.sleep(50); }\n}","handlingStrategy":"retry","validationCode":"// Poll endpoint status before re-adding, or serialize close/add with the driver's client lock and small delay:\nThread.sleep(100); // after close(), before addPublication on the same URI","typeGuard":null,"tryCatchPattern":"catch (ControlProtocolException e) {\n  if (e.errorCode() == AeronException.Category.ERROR.getCode() && e.getMessage().contains(\"CLOSING state\")) {\n    backoffAndRetryAddPublication(uri, streamId); // exponential backoff, e.g. 50ms..1s\n  } else throw e;\n}","preventionTips":["Avoid tight close/reopen loops on the same channel URI","Retry any ControlProtocolException with RESOURCE_TEMPORARILY_UNAVAILABLE","Reuse long-lived publications instead of recreating them","Add jittered backoff in reconnect logic"],"tags":["aeron","transient","retry","channel-endpoint"],"backgroundTag":"request-timeout","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"}