aeron-io/aeron · error · ArchiveException
connection to the archive has been closed
Error message
connection to the archive has been closed
What it means
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.
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
Example fix
// before
archive.stopReplay(replayId); // throws if connection closed
// after
if (!archive.isClosed()) {
try {
archive.stopReplay(replayId);
} catch (ArchiveException e) {
archive = AeronArchive.connect(ctx); // reconnect
archive.stopReplay(replayId);
}
} Defensive patterns
Strategy: try-catch
Validate before calling
if (archive == null || archive.isClosed()) { archive = AeronArchive.connect(ctx); } Type guard
boolean usable(AeronArchive a) { return a != null && !a.isClosed(); } Try / catch
try { archiveCommand(); } catch (ArchiveException e) { archive.close(); archive = AeronArchive.connect(ctx); archiveCommand(); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- failed to send detach segments request
- failed to send invalidate recording request
- failed to send list recording subscriptions request
- failed to send replicate request
- failed to send stop replication request
AI-assisted analysis of aeron-io/aeron@6d60124e15 (2026-09-12).
Data as JSON: /api/errors/6aca00bc06d6f802.
Report an issue: GitHub.
Appendix: source
Thrown at aeron-archive/src/main/java/io/aeron/archive/client/ArchiveProxy.java:1483
return offer(updateChannelRequestEncoder.encodedLength());
}
private boolean offer(final int length)
{
retryIdleStrategy.reset();
int attempts = retryAttempts;
while (true)
{
final long position = publication.offer(buffer, 0, MessageHeaderEncoder.ENCODED_LENGTH + length);
if (position > 0)
{
return true;
}
if (position == Publication.CLOSED)
{
throw new ArchiveException("connection to the archive has been closed");
}
if (position == Publication.NOT_CONNECTED)
{
throw new ArchiveException("connection to the archive is no longer available");
}
if (position == Publication.MAX_POSITION_EXCEEDED)
{
throw new ArchiveException(
"offer failed due to max position being reached: term-length=" + publication.termBufferLength());
}
if (--attempts <= 0)
{
return false;
}
View on GitHub (pinned to 6d60124e15)