使用 enterprisedt 的 ftp java 框架调用disconnect()时连接重置

发布于 2024-09-03 00:19:18 字数 1999 浏览 9 评论 0原文

我在使用 enterpriset java ftp 框架从 ftp 服务器断开连接时遇到问题。< /a>

我无法在 FileTransferClient 对象上调用 disconnect() 而不出现错误。

除了连接到服务器,然后断开连接之外,我没有做任何事情:

        // create client
        log.info("Creating FTP client");
        ftp = new FileTransferClient();

        // set remote host
        log.info("Setting remote host");
        ftp.setRemoteHost(host);
        ftp.setUserName(username);
        ftp.setPassword(password);

        // connect to the server
        log.info("Connecting to server " + host);
        ftp.connect();
        log.info("Connected and logged in to server " + host);

        // Shut down client
        log.info("Quitting client");
        ftp.disconnect();

        log.info("Example complete");

运行此程序时,日志显示:

INFO [test] 28 maj 2010 16:57:20.216 : Creating FTP client
INFO [test] 28 maj 2010 16:57:20.263 : Setting remote host
INFO [test] 28 maj 2010 16:57:20.263 : Connecting to server x
INFO [test] 28 maj 2010 16:57:20.979 : Connected and logged in to server x
INFO [test] 28 maj 2010 16:57:20.979 : Quitting client
ERROR [FTPControlSocket] 28 maj 2010 16:57:21.026 : Read failed ('' read so far)

并且堆栈跟踪:

com.enterprisedt.net.ftp.ControlChannelIOException: Connection reset
at com.enterprisedt.net.ftp.FTPControlSocket.readLine(FTPControlSocket.java:1029)
at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:1089)
at com.enterprisedt.net.ftp.FTPControlSocket.sendCommand(FTPControlSocket.java:988)
at com.enterprisedt.net.ftp.FTPClient.quit(FTPClient.java:4044)
at com.enterprisedt.net.ftp.FileTransferClient.disconnect(FileTransferClient.java:1034)
at test.main(test.java:46)

应该注意的是,我可以毫无问题地连接并与服务器一起执行操作,例如获取当前工作目录中的文件列表。但由于某种原因我无法断开连接!我尝试过使用主动模式和被动模式。

上面的例子是从他们自己的例子中复制/粘贴的。我无法通过谷歌搜索找到任何与此相关的内容,所以我希望您有任何建议或解决此问题的经验。

I'm having trouble disconnecting from a ftp-server, using the enterprisedt java ftp framework.

I can simply not call disconnect() on a FileTransferClient object without getting an error.

I do not do anything, besides connecting to the server, and then disconnecting:

        // create client
        log.info("Creating FTP client");
        ftp = new FileTransferClient();

        // set remote host
        log.info("Setting remote host");
        ftp.setRemoteHost(host);
        ftp.setUserName(username);
        ftp.setPassword(password);

        // connect to the server
        log.info("Connecting to server " + host);
        ftp.connect();
        log.info("Connected and logged in to server " + host);

        // Shut down client
        log.info("Quitting client");
        ftp.disconnect();

        log.info("Example complete");

When running this, the log reads:

INFO [test] 28 maj 2010 16:57:20.216 : Creating FTP client
INFO [test] 28 maj 2010 16:57:20.263 : Setting remote host
INFO [test] 28 maj 2010 16:57:20.263 : Connecting to server x
INFO [test] 28 maj 2010 16:57:20.979 : Connected and logged in to server x
INFO [test] 28 maj 2010 16:57:20.979 : Quitting client
ERROR [FTPControlSocket] 28 maj 2010 16:57:21.026 : Read failed ('' read so far)

And the stacktrace:

com.enterprisedt.net.ftp.ControlChannelIOException: Connection reset
at com.enterprisedt.net.ftp.FTPControlSocket.readLine(FTPControlSocket.java:1029)
at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:1089)
at com.enterprisedt.net.ftp.FTPControlSocket.sendCommand(FTPControlSocket.java:988)
at com.enterprisedt.net.ftp.FTPClient.quit(FTPClient.java:4044)
at com.enterprisedt.net.ftp.FileTransferClient.disconnect(FileTransferClient.java:1034)
at test.main(test.java:46)

It should be noted, that I without problems can connect, and do stuff with the server, like getting a list of files in the current working directory. But I cant, for some reason, disconnect! I've tried using both active and passive mode.

The above example is by the way copy/pasted from their own example. I cannot fint ANYTHING related to this by doing a Google-search, so I was hoping you have any suggestions, or experience with this issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末骤雨初歇 2024-09-10 00:19:19

尝试启用跟踪,

com.enterprisedt.util.debug.Logger.setLevel(com.enterprisedt.util.debug.Level.DEBUG);

这将使您观察库和 ftp 服务器之间的通信。

尝试使用命令行客户端打开与 ftp 服务器的连接。连接、登录、验证一切正常。然后输入quot quit。这会向 ftp 服务器发送显式的 quit 命令。您应该收到 221226 响应。如果您收到任何其他代码,或者连接刚刚关闭,那么您将遇到不兼容的 FTP 服务器。

如果是这种情况,您还可以尝试使用 disconnect(true) 因为它只是关闭连接,而不是尝试正常关闭。

Try enabling the traces with

com.enterprisedt.util.debug.Logger.setLevel(com.enterprisedt.util.debug.Level.DEBUG);

That will let you observe the communication between the library and the ftp server.

Try opening a connection to the ftp server with a command line client. Connect, log in, verify that is all working. Then type quot quit. That sends an explicit quit command to the ftp server. You should get either a 221 or a 226 response. If you get any other code, or if the connection is just closed, then you're up against a non-compliant FTP server.

If that's the case, you can also try using disconnect(true) as that just closes connections rather than attempting a graceful shutdown.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文