{"record":{"id":"6aca00bc06d6f802","repo":"aeron-io/aeron","slug":"connection-to-the-archive-has-been-closed","errorCode":null,"errorMessage":"connection to the archive has been closed","messagePattern":"connection to the archive has been closed","errorType":"exception","errorClass":"ArchiveException","httpStatus":null,"severity":"error","filePath":"aeron-archive/src/main/java/io/aeron/archive/client/ArchiveProxy.java","lineNumber":1483,"sourceCode":"        return offer(updateChannelRequestEncoder.encodedLength());\n    }\n\n    private boolean offer(final int length)\n    {\n        retryIdleStrategy.reset();\n\n        int attempts = retryAttempts;\n        while (true)\n        {\n            final long position = publication.offer(buffer, 0, MessageHeaderEncoder.ENCODED_LENGTH + length);\n            if (position > 0)\n            {\n                return true;\n            }\n\n            if (position == Publication.CLOSED)\n            {\n                throw new ArchiveException(\"connection to the archive has been closed\");\n            }\n\n            if (position == Publication.NOT_CONNECTED)\n            {\n                throw new ArchiveException(\"connection to the archive is no longer available\");\n            }\n\n            if (position == Publication.MAX_POSITION_EXCEEDED)\n            {\n                throw new ArchiveException(\n                    \"offer failed due to max position being reached: term-length=\" + publication.termBufferLength());\n            }\n\n            if (--attempts <= 0)\n            {\n                return false;\n            }\n","sourceCodeStart":1465,"sourceCodeEnd":1501,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-archive/src/main/java/io/aeron/archive/client/ArchiveProxy.java#L1465-L1501","documentation":"Thrown from ArchiveProxy's offer loop when the control request Publication position returns Publication.CLOSED, meaning the underlying publication was closed and no further commands (keepAlive, startRecording, stopReplay, etc.) can be sent to the archive. Indicates the archive connection is definitively gone, not merely temporarily disconnected.","triggerScenarios":"Any ArchiveProxy command offer (keepAlive, closeSession, startRecording, stopRecording, stopRecordingByIdentity, stopReplay) after the control request publication has been closed — e.g. Aeron driver closed it, archive session closed, or the AeronArchive was closed concurrently.","commonSituations":"Using an AeronArchive after calling close(); archive terminated the session and the publication was closed; Aeron driver shutdown (e.g. media driver stopped); application bug sharing an archive client across threads that closed it.","solutions":["Stop using the closed AeronArchive/ArchiveProxy; create a new connection via AeronArchive.connect()","Check the Aeron driver error log for why the publication was closed","Ensure no code path closes the Aeron or archive client while other threads use it","Verify the archive is still running and the session was not terminated server-side"],"exampleFix":"// before\narchive.stopReplay(replayId); // throws if connection closed\n// after\nif (!archive.isClosed()) {\n    try {\n        archive.stopReplay(replayId);\n    } catch (ArchiveException e) {\n        archive = AeronArchive.connect(ctx); // reconnect\n        archive.stopReplay(replayId);\n    }\n}","handlingStrategy":"try-catch","validationCode":"if (archive == null || archive.isClosed()) { archive = AeronArchive.connect(ctx); }","typeGuard":"boolean usable(AeronArchive a) { return a != null && !a.isClosed(); }","tryCatchPattern":"try { archiveCommand(); } catch (ArchiveException e) { archive.close(); archive = AeronArchive.connect(ctx); archiveCommand(); }","preventionTips":["Never use AeronArchive after close(); guard with an isClosed check","Single-owner lifecycle management for archive clients (avoid cross-thread close)","Monitor Aeron driver errors that close publications","Detect archive-side session termination via the control response poller"],"tags":["aeron-archive","publication-closed","connection-closed","control-session"],"backgroundTag":"connection-refused","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"}