【问题标题】:SFTP connection error ( transport protocol disconnected)SFTP 连接错误(传输协议已断开)
【发布时间】:2017-01-17 14:44:27
【问题描述】:

我在尝试连接到 (Windows) SFTP 服务器时遇到问题。 SFTP 服务器的名称是 Secure Bridge(适用于 Windows)。 这很奇怪,因为它看起来有时可以正常工作,但有时也不能正常工作。它有时会显示如下错误。 我的来源如下。你可以帮帮我吗?为什么会出现这个错误?

[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;
}

【问题讨论】:

  • 您是否可以使用任何 SFTP 客户端(例如 filezilla)连接到同一台服务器?

标签: java protocols sftp connect transport


【解决方案1】:

看起来解决了。我已将 RAM 大小从 1G 升级到 3G。然后它工作正常。测试 FTP 服务器位于 VMWare 中。我不知道 RAM 大小与错误消息有关。所以该错误与我的PC环境有关。

谢谢。

【讨论】:

    猜你喜欢
    • 2021-05-19
    • 1970-01-01
    • 2022-11-21
    • 2020-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-31
    相关资源
    最近更新 更多