title: com.jcraft.jsch.JSchException: timeout: socket is not established
body: <p>I am trying to upload a file to a server (with java) where I have an acount and the SFTP connection stopped working (for a timeout problem I guess). I want to know is there a way to reset this connection and get it working. This is the function:</p>
  
  <pre><code>    public static void upload(File file, boolean retry) {
      try 
      {
          System.out.println("Uplodaing file " + file.getName());
  
          JSch jsch = new JSch();
          Session session = jsch.getSession("****", "*****", 22);
          session.setPassword("*****");
  
          java.util.Properties config = new java.util.Properties();
          config.put("StrictHostKeyChecking", "no");
          session.setConfig(config);
          session.setTimeout(5);
  
          System.out.println("Establishing connection");
          session.connect(10);
  
  
          Channel channel = session.openChannel("sftp");
          channel.connect();
          ChannelSftp sftpChannel = (ChannelSftp) channel;
  
          if (!retry)
              sftpChannel.put(file.getAbsolutePath(), file.getName(),new SystemOutProgressMonitor(), ChannelSftp.OVERWRITE);
          else
              sftpChannel.put(file.getAbsolutePath(), file.getName(),new SystemOutProgressMonitor(), ChannelSftp.RESUME);
  
          channel.disconnect();
          session.disconnect();
      } 
      catch (Exception e) 
      {
          e.printStackTrace();
          upload(file, false);
      }
  
  }
  </code></pre>