title: ftp Connection timed out exception
body: <p>I am trying to connect to a FTP site and upload/download a file. I was able to connect via browser and FileZilla. So I know for sure that it works. But when I try to access it via my java program, I get this exception. Please any help will be appreciated.<br>
  My Java Class (constructor)</p>
  
  <pre><code>public TriFtpClient() {
      tri = new FTPClient();
      String host = InkAndTonerProperties.getSingleton().getProperty(
              "ftpDomain");
      int reply;
      try {
          tri.addProtocolCommandListener(new PrintCommandListener(
                  new PrintWriter(System.out), true));
          tri.connect(host, 21);
          log.debug("default port = " + tri.getDefaultPort());
          reply = tri.getReplyCode();
          if (!FTPReply.isPositiveCompletion(reply)) {
              tri.disconnect();
              log.error("Exception in connecting to FTP Server");
          }
          tri.login(
                  InkAndTonerProperties.getSingleton().getProperty(
                          "ftpUserId"), InkAndTonerProperties.getSingleton()
                          .getProperty("ftpPassword"));
          tri.enterLocalPassiveMode();
      } catch (IOException e) {
          if (tri.isConnected()) {
              log.error("it is connected.");
              try {
                  tri.disconnect();
              } catch (IOException f) {
                  // do nothing
              }
          }
          log.error("Failed to connect and login", e);
      }
  }
  </code></pre>
  
  <p>// method for upload<br>
  // method for download</p>
  
  <p><b>stack trace</b></p>
  
  <pre><code>java.net.ConnectException: Connection timed out: connect
  at java.net.DualStackPlainSocketImpl.connect0(Native Method)
  at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
  at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
  at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
  at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
  at java.net.PlainSocketImpl.connect(Unknown Source)
  </code></pre>