title: HTTPS Client with FTP Login Error: javax.net.ssl.SSLException: 502 SSLv23/TLSv1 java
body: <p>I am pretty new to Java so the more you explain the more I learn, and less questions I will ask ;) I am trying to program a client to connect to ftp.availity.com but I cannot for the life of me get the client to login. I have tried changing the port numbers (443, 20, etc) but they all do not return a response in the console log and it only returns a timeout error. The only one I can get some action with is port 21. I know this is FTP and I think that may be where there error is coming from but I have no idea how to correct it because obviously changing the port # doesn't correct the issue. Any help would be appreciated! </p>
  
  <p>Here's my code: </p>
  
  <pre><code>import java.io.IOException;
  import org.apache.commons.net.ftp.*;
  
  public class FTPApp {
  private static void showServerReply(FTPSClient ftpClient) {
      String[] replies = ftpClient.getReplyStrings();
      if (replies != null &amp;&amp; replies.length &gt; 0) {
          for (String aReply : replies) {
              System.out.println("SERVER: " + aReply);
          }
      }
  }
  
  public static void main(String[] args) {
  
      String server = "ftp.availity.com";
      int port = 21;
      String user = "user";
      String pass = "pass";
      FTPSClient ftpClient = new FTPSClient();
  
      try {
          ftpClient.connect( server, port);   
          showServerReply(ftpClient);
          int replyCode = ftpClient.getReplyCode();
          if (!FTPReply.isPositiveCompletion(replyCode)) {
              System.out.println("Operation failed. Server reply code: " + replyCode);
              return;
          }
          boolean success = ftpClient.login(user, pass);
          showServerReply(ftpClient);
          if (!success) {
              System.out.println("Could not login to the server");
              return;
          } else {
              System.out.println("LOGGED IN SERVER");
          }
      } catch (IOException ex) {
          System.out.println("Oops! Something wrong happened");
          ex.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here's the error: </p>
  
  <pre><code>Oops! Something wrong happened
  javax.net.ssl.SSLException: 502 SSLv23/TLSv1
  at org.apache.commons.net.ftp.FTPSClient.execAUTH(FTPSClient.java:242)
  at org.apache.commons.net.ftp.FTPSClient._connectAction_(FTPSClient.java:225)
  at org.apache.commons.net.SocketClient._connect(SocketClient.java:244)
  at org.apache.commons.net.SocketClient.connect(SocketClient.java:202)
  at FTPApp.main(FTPApp.java:23)
  </code></pre>