{"record":{"id":"78603dcda4ca02f1","repo":"apache/seatunnel","slug":"connection-failed-78603d","errorCode":"CONNECTION_FAILED","errorMessage":"Failed to initialize SNMP SET client for agent {host}:{port}","messagePattern":"Failed to initialize SNMP SET client for agent (.+?):(.+?)","errorType":"error_code","errorClass":"SnmpConnectorException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/sink/SnmpSinkWriter.java","lineNumber":47,"sourceCode":"/** Writes each row as one synchronous SNMPv2c SET request. */\npublic final class SnmpSinkWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {\n\n    private final SnmpSinkConfig config;\n    private final SnmpSinkRowConverter converter;\n    private final SnmpSetClient client;\n\n    public SnmpSinkWriter(SnmpSinkConfig config, SeaTunnelRowType rowType) {\n        this(config, rowType, Snmp4jSetClient::new);\n    }\n\n    SnmpSinkWriter(\n            SnmpSinkConfig config, SeaTunnelRowType rowType, SnmpSetClientFactory clientFactory) {\n        this.config = config;\n        this.converter = new SnmpSinkRowConverter(config, rowType);\n        try {\n            this.client = clientFactory.create(config);\n        } catch (IOException e) {\n            throw new SnmpConnectorException(\n                    SnmpConnectorErrorCode.CONNECTION_FAILED,\n                    \"Failed to initialize SNMP SET client for agent \"\n                            + config.getHost()\n                            + \":\"\n                            + config.getPort(),\n                    e);\n        }\n    }\n\n    @Override\n    public void write(SeaTunnelRow row) {\n        SnmpSetRequest request = converter.convert(row);\n        try {\n            client.set(request);\n        } catch (IOException e) {\n            throw new SnmpConnectorException(\n                    SnmpConnectorErrorCode.WRITE_FAILED,\n                    \"Failed to set OID \"","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/sink/SnmpSinkWriter.java#L29-L65","documentation":"SnmpSinkWriter's constructor creates the SNMP SET client via SnmpSetClientFactory.create(config). If client creation (Snmp.open/transport setup) throws an IOException, the writer rethrows it as SnmpConnectorException with CONNECTION_FAILED. This fails writer construction, meaning the sink task cannot start against this agent.","triggerScenarios":"Constructing SnmpSinkWriter(config, rowType, clientFactory) when clientFactory.create(config) throws IOException — typically SNMP4J transport/listener initialization failure for host:port.","commonSituations":"Invalid or unresolvable host configured in the sink; invalid SNMP version or community settings in SnmpSinkConfig; SNMPv3 engine discovery failure on construction; local resource issues binding a UDP socket.","solutions":["Check the sink config: host must resolve (DNS/hosts entry) and port must match the agent (usually 161).","Validate SnmpSinkConfig fields (version, community, timeouts) are within SNMP4J-supported values.","For SNMPv3, verify USM user/auth/priv settings; engine discovery failures surface at init time.","Inspect the wrapped cause IOException for the underlying transport error.","Pre-test connectivity from the SeaTunnel worker node, since init happens on the task machine."],"exampleFix":"// before\nhost = \"snmp-prod.internal\"  // unresolvable from worker\n// after\nhost = \"10.0.0.5\" // or add DNS entry reachable from the SeaTunnel worker","handlingStrategy":"validation","validationCode":"// validate before creating the writer\nInetAddress.getByName(config.getHost()); // throws UnknownHostException early\nif (config.getPort() <= 0 || config.getPort() > 65535) throw new IllegalArgumentException(\"bad port\");\n// optional live probe\nsnmpGetProbe(config.getHost(), config.getPort(), config.getCommunity(), 5000);","typeGuard":null,"tryCatchPattern":"try {\n    SnmpSinkWriter writer = new SnmpSinkWriter(config, rowType, clientFactory);\n} catch (SnmpConnectorException e) {\n    if (e.getCode() == SnmpConnectorErrorCode.CONNECTION_FAILED)\n        LOG.error(\"SNMP sink init failed for {}:{}\", config.getHost(), config.getPort(), e.getCause());\n    throw e;\n}","preventionTips":["Resolve and probe host:port from the actual SeaTunnel worker node, not the submitter.","Keep a health-check job that does a GET against each agent before scheduled runs.","Validate SNMP version/credentials in config before submission.","Read getCause() to distinguish DNS vs transport vs auth init failures."],"tags":["snmp","initialization","connection","sink"],"backgroundTag":"module-init-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}