{"record":{"id":"d041efba874e9cfd","repo":"pentaho/pentaho-kettle","slug":"max-connection-attempts-reached","errorCode":null,"errorMessage":"Max connection attempts reached","messagePattern":"Max connection attempts reached","errorType":"exception","errorClass":"KettleJobException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/entries/sftp/SFTPClient.java","lineNumber":190,"sourceCode":"\n  private static byte[] getFileContent( Bowl bowl, String vfsFileName ) throws KettleFileException, IOException {\n    return FileObjectUtils.getContentAsByteArray( KettleVFS.getInstance( bowl ).getFileObject( vfsFileName ) );\n  }\n\n  public void login( String password ) throws KettleJobException {\n    this.password = password;\n    // up to a total of 6 seconds delay max per connection attempt\n    int maxConnectionAttempts = 62;\n    int delayBetweenEachAttempts = 100; // milliseconds\n\n    while ( true ) {\n      try {\n        if ( tryCreateNewConnection( ) ) {\n          break;\n        }\n\n        if ( --maxConnectionAttempts <= 0 ) {\n          throw new KettleJobException( \"Max connection attempts reached\" );\n        }\n        Thread.sleep( delayBetweenEachAttempts );\n        // incrementing delay by 100 milliseconds\n        delayBetweenEachAttempts += 100;\n\n      } catch ( InterruptedException ex ) {\n        Thread.currentThread().interrupt();\n        throw new KettleJobException( \"Interrupted during a retry \", ex );\n      } catch ( Exception e ) {\n        throw new KettleJobException( \"An unexpected error has occurred \", e );\n      }\n    }\n  }\n\n  private boolean tryCreateNewConnection(  ) {\n    try {\n      session.setPassword( this.getPassword() );\n      java.util.Properties config = new java.util.Properties();","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/entries/sftp/SFTPClient.java#L172-L208","documentation":"SFTPClient.login() retries tryCreateNewConnection() up to a configurable number of attempts, decrementing maxConnectionAttempts each round. If every attempt fails and the counter reaches zero, it throws this KettleJobException indicating the server could not be reached within the retry budget.","triggerScenarios":"Calling login() (directly or via testDir/testDirNoFiles/SFTP job entry execute) where tryCreateNewConnection() returns false on every retry until maxConnectionAttempts <= 0.","commonSituations":"SFTP server down or unreachable (network/firewall); wrong host/port; too many connection attempts configured too low for a slow server; server rejecting repeated handshakes.","solutions":["Verify host, port, and network reachability (ping/nc to the SFTP port).","Increase the max connection attempts and/or delay settings to tolerate slow servers.","Check SFTP server logs and firewall rules for dropped connections.","Inspect tryCreateNewConnection's swallowed failure cause (enable logging) to see why connections fail."],"exampleFix":"// before (job entry config)\nmaxConnectionAttempts = 1; delay = 0;\n// after\nmaxConnectionAttempts = 5; delay = 1000;","handlingStrategy":"retry","validationCode":"// before login\nboolean reachable;\ntry (Socket s = new Socket()) { s.connect(new InetSocketAddress(host, port), 3000); reachable = true; }\ncatch (IOException e) { reachable = false; }","typeGuard":null,"tryCatchPattern":"try {\n  client.login();\n} catch (KettleJobException e) {\n  if (\"Max connection attempts reached\".equals(e.getMessage())) alertOps(\"SFTP unreachable: \" + host);\n}","preventionTips":["Configure retries and delay proportional to network flakiness.","Monitor SFTP server availability and alert before jobs run.","Keep total retry window below job timeout settings."],"tags":["sftp","connection","retry","network"],"backgroundTag":"connection-refused","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}