2016-09-09 11 views
0

(Windows) SFTP 서버에 연결하려고 할 때 문제가 있습니다. SFTP 서버의 이름은 Secure Bridge입니다 (Windows의 경우). 가끔 제대로 작동하지만 언젠가는 작동하지 않기 때문에 이상합니다. 언젠가는 아래와 같은 오류를 보여줍니다. 내 출처가 아래에 있습니다. 당신이 나를 도울 수? 이 오류가 발생하는 이유는 무엇입니까?SFTP 연결 오류 (전송 프로토콜 연결이 끊김)

[Error] 

     java.io.IOException: The transport protocol disconnected 
     com.sshtools.j2ssh.transport.TransportProtocolCommon.readMessage(Unknown Source) 
     com.sshtools.j2ssh.transport.TransportProtocolCommon.sendNewKeys(Unknown Source) 
     com.sshtools.j2ssh.transport.TransportProtocolCommon.beginKeyExchange(Unknown Source) 
     com.sshtools.j2ssh.transport.TransportProtocolCommon.onMsgKexInit(Unknown Source) 
    com.sshtools.j2ssh.transport.TransportProtocolCommon.startBinaryPacketProtocol(Unknown Source) 
    com.sshtools.j2ssh.transport.TransportProtocolCommon.run(Unknown Source) 
    java.lang.Thread.run(Unknown Source) 




private SshClient client = null; 
private PasswordAuthenticationClient auth = null; 
private SftpClient sftp = null; 

public boolean connect(String server, 
         int port, 
         String user, 
         String pwd) throws Exception { 

    try { 

     if (server == null || user == null || pwd == null) { 
      logger.error("Parameter is null!"); 
      throw new Exception("Parameter is null!"); 
     } 

     SshConnectionProperties params = new SshConnectionProperties(); 
     params.setHost(server); 
     params.setPort(port); 

     HostKeyVerification key = new HostKeyVerification() { 

      @Override 
      public boolean verifyHost(String arg0, 
             SshPublicKey arg1) throws TransportProtocolException { 

       return true; 
      } 
     }; 

     client = new SshClient(); 
     client.setSocketTimeout(10000); 
     client.connect(params, key); 

     auth = new PasswordAuthenticationClient(); 
     auth.setUsername(user); 
     auth.setPassword(pwd); 

     int result = client.authenticate(auth); 

     if (result != AuthenticationProtocolState.COMPLETE) { 
      throw new Exception("Login to " + server + ":" + port + " " + user + "/" + pwd + " failed"); 
     } 

     sftp = client.openSftpClient(); 

    } catch (Exception e) { 
     logger.error(e); 
     logout(); 
     return false; 
    } 

    return true; 
} 
+0

filezilla와 같은 SFTP 클라이언트를 사용하여 동일한 서버에 연결할 수 있습니까? –

답변

0

외관상입니다. 1G에서 3G로 RAM 크기를 업그레이드했습니다. 그런 다음 제대로 작동합니다. 테스트 FTP 서버는 VMWare에 있습니다. RAM 크기가 오류 메시지와 관련이 있는지 알지 못했습니다. 그래서 그 오류는 내 PC 상황과 관련이 있습니다.

감사합니다.