apache/seatunnel · warning · SnmpConnectorException
CLOSE_FAILED
CLOSE_FAILED
Error message
Failed to close SNMP SET client for agent {host}:{port} What it means
SnmpSinkWriter.close() releases the SNMP client; if client.close() throws IOException, it is rethrown as SnmpConnectorException with CLOSE_FAILED. The underlying SNMP session (transport listener) could not be shut down cleanly during task cleanup.
Source
Thrown at seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/sink/SnmpSinkWriter.java:80
} catch (IOException e) {
throw new SnmpConnectorException(
SnmpConnectorErrorCode.WRITE_FAILED,
"Failed to set OID "
+ request.getOid()
+ " on SNMP agent "
+ config.getHost()
+ ":"
+ config.getPort(),
e);
}
}
@Override
public void close() {
try {
client.close();
} catch (IOException e) {
throw new SnmpConnectorException(
SnmpConnectorErrorCode.CLOSE_FAILED,
"Failed to close SNMP SET client for agent "
+ config.getHost()
+ ":"
+ config.getPort(),
e);
}
}
interface SnmpSetClientFactory {
SnmpSetClient create(SnmpSinkConfig config) throws IOException;
}
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Check the wrapped cause; if it is 'socket already closed' style, the failure is benign and lifecycle bookkeeping should prevent double close.
- Ensure close() is invoked once per writer lifecycle (avoid calling after task teardown).
- Log-and-continue may be appropriate for close failures since data already written cannot be undone by a retry.
- Verify no other thread is using the client concurrently while close runs.
- If persistent, restart the worker to reclaim transport resources.
Example fix
// before
writer.close();
writer.close(); // second call fails
// after
if (!writerClosed) { writer.close(); writerClosed = true; } Defensive patterns
Strategy: fallback
Validate before calling
if (!writerClosed) { /* safe to close */ } Try / catch
try {
writer.close();
} catch (SnmpConnectorException e) {
LOG.warn("SNMP sink close failed for {}:{} (data already flushed)", config.getHost(), config.getPort(), e);
} Prevention
- Invoke close exactly once per writer lifecycle.
- Treat close failures as non-fatal: log and continue, since data was already sent.
- Avoid concurrent use of the client while closing.
- In tests, use @AfterAll-style single teardown to prevent repeated closes.
When it happens
Trigger: Calling close() on SnmpSinkWriter when the delegated Snmp4jSetClient.close() (SNMP4J snmp.close()) throws IOException — transport already broken or socket already closed.
Common situations: Agent/network died before close so the UDP transport is in an error state; close called twice (double lifecycle invocation); JVM teardown racing with the close; test harness closing the client repeatedly.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- WRITER_CLOSE_FAILED
- WRITER_OPERATION_FAILED
- CLOSE_CONNECTION_FAILED
- Failed to close HugeGraph sink writer
- Failed to close %s via JDBC.
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/763f18d1dcec7efb.
Report an issue: GitHub.