{"record":{"id":"e6fe678997a76a62","repo":"apache/seatunnel","slug":"timed-out-after-actualseconds-seconds-while-wait","errorCode":null,"errorMessage":"Timed out after <actualSeconds> seconds while waiting to connect to MySQL at <hostname>:<port> with user '<username>'","messagePattern":"Timed out after <actualSeconds> seconds while waiting to connect to MySQL at <hostname>:<port> with user '<username>'","errorType":"exception","errorClass":"DebeziumException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlStreamingChangeEventSource.java","lineNumber":1220,"sourceCode":"                            for (Thread t : binaryLogClientThreads.values()) {\n                                if (t.getName().startsWith(KEEPALIVE_THREAD_NAME) && t.isAlive()) {\n                                    LOGGER.info(\"Keepalive thread is running\");\n                                    keepAliveThreadRunning = true;\n                                }\n                            }\n                            metronome.pause();\n                        }\n                    }\n                } catch (TimeoutException e) {\n                    // If the client thread is interrupted *before* the client could connect, the\n                    // client throws a timeout exception\n                    // The only way we can distinguish this is if we get the timeout exception\n                    // before the specified timeout has\n                    // elapsed, so we simply check this (within 10%) ...\n                    long duration = clock.currentTimeInMillis() - started;\n                    if (duration > (0.9 * timeout)) {\n                        double actualSeconds = TimeUnit.MILLISECONDS.toSeconds(duration);\n                        throw new DebeziumException(\n                                \"Timed out after \"\n                                        + actualSeconds\n                                        + \" seconds while waiting to connect to MySQL at \"\n                                        + connectorConfig.hostname()\n                                        + \":\"\n                                        + connectorConfig.port()\n                                        + \" with user '\"\n                                        + connectorConfig.username()\n                                        + \"'\",\n                                e);\n                    }\n                    // Otherwise, we were told to shutdown, so we don't care about the timeout\n                    // exception\n                } catch (AuthenticationException e) {\n                    throw new DebeziumException(\n                            \"Failed to authenticate to the MySQL database at \"\n                                    + connectorConfig.hostname()\n                                    + \":\"","sourceCodeStart":1202,"sourceCodeEnd":1238,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/io/debezium/connector/mysql/MySqlStreamingChangeEventSource.java#L1202-L1238","documentation":"The streaming source executes a JDBC connect to MySQL inside a loop that is expected to abort via InterruptedIOException/timeout when the configured connect timeout elapses. To distinguish a genuine network timeout from a too-short timeout or an interrupted connect, it measures elapsed wall-clock time: if the exception arrived only after >=90% of the timeout had really passed, it concludes the server was actually unreachable and throws this DebeziumException naming host, port, user, and measured seconds.","triggerScenarios":"JDBC connection attempts to connectorConfig.hostname():port keep failing/timing out until the cumulative elapsed time exceeds 0.9 * the configured connect timeout (database.connection.timeout / connection.timeout.ms), with user <username>; thrown from the MySqlStreamingChangeEventSource constructor.","commonSituations":"MySQL host unreachable or DNS misconfigured; firewall/security group blocking 3306; MySQL max_connections exhausted or server overloaded; wrong port or VPC/network peering missing; user account or host grants fine but network blackhole causes silent drop; containerized setups using 'localhost' from inside another container.","solutions":["Verify network reachability from the connector host: `mysql -h <hostname> -P <port> -u <username> -p` or `nc -vz <hostname> <port>`.","Increase the connect timeout option (e.g. `database.connection.timeout` / serverTimezone-compatible JDBC connectTimeout in the connector config) if the server is merely slow to accept connections.","Check MySQL server state: is it running, is `max_connections` exhausted, are there firewall/security-group rules allowing the connector's IP?","Fix hostname resolution (use the correct service DNS/IP; replace 'localhost' with the MySQL container/service name in containerized deployments).","Confirm the account exists and is allowed from the connector's source host (`SHOW GRANTS FOR 'user'@'host'`) — though a plain auth refusal usually surfaces as a different error."],"exampleFix":"// before: hostname unreachable from inside the job container\nurl = \"jdbc:mysql://localhost:3306/orders\"\n\n// after: use the service-resolvable host and a longer timeout\nurl = \"jdbc:mysql://mysql.database.svc.cluster.local:3306/orders?connectTimeout=60000\"","handlingStrategy":"retry","validationCode":"// preflight check before starting the streaming source\nif (!pingMysql(host, port, timeoutMillis)) {\n  throw new IllegalStateException(\"Cannot reach MySQL at \" + host + \":\" + port + \" — fix network/credentials first\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  startStreamingSource(config);\n} catch (DebeziumException e) {\n  if (e.getMessage().startsWith(\"Timed out after\") && e.getMessage().contains(\"waiting to connect to MySQL\")) {\n    retryWithBackoff(() -> startStreamingSource(config), 3);\n  } else throw e;\n}","preventionTips":["Run a connectivity preflight (nc/mysql client) from the same network the connector runs in","Use service DNS names, not localhost, in containerized deployments","Set an explicit generous connect timeout in JDBC URL/connector config","Monitor MySQL max_connections and firewall/security-group rules","Wrap connector startup in bounded retry with backoff for transient network outages"],"tags":["mysql","connection","timeout","network","jdbc"],"backgroundTag":"connection-timeout","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}