【问题标题】:Can't connect to vsftpd server with alpakka (akka-streams)无法使用 alpakka (akka-streams) 连接到 vsftpd 服务器
【发布时间】:2019-06-28 13:54:39
【问题描述】:

我正在尝试使用 Docker 映像中的 vsftpd server 为 Alpakka FTP-Source 连接器重新创建 traversal example,但似乎无法连接。任何如何调整代码的指针都非常受欢迎:

FtpSettings ftpSettings = FtpSettings
  .create(InetAddress.getLocalhost())
  .withPort(21)
  .withCredentials(FtpCredentials.NonAnonFtpCredentials.create("news", "test"))
  .withBinary(true)
  .withPassiveMode(true)
  .withConfigureConnectionConsumer(
    (FTPClient ftpClient) -> {
      ftpClient.addProtocolCommandListener(
        new PrintCommandListener(new PrintWriter(System.out), true));
    });

Source<FtpFile, NotUsed> ftp = Ftp.ls("/", ftpSettings);
ftp.to(Sink.foreach(s -> LOGGER.info(s.name())));

仅供参考:登录信息有效,例如使用 filezilla。

【问题讨论】:

  • 原来使用PASV_ADDRESS=foo 的容器设置是问题所在。为什么 Filezilla 能够解决它,但我无法理解。

标签: ftp akka alpakka vsftpd


【解决方案1】:

Source.to 返回一个RunnableGraph,这是一个你仍然需要“运行”的“蓝图”:

import akka.actor.ActorSystem;
import akka.stream.Materializer;
import akka.stream.ActorMaterializer;

// Create the blueprint:
RunnableGraph blueprint = ftp.to(Sink.foreach(s -> LOGGER.info(s.name())));

// Create the system to run the stream in:
ActorSystem system = ActorSystem.create();
Materializer materializer = ActorMaterializer.create(system);

// Run the stream:
blueprint.run(materializer);

您也可以使用“runWith”简写:

ftp.runWith(Sink.foreach(s -> LOGGER.info(s.name())), materializer);

【讨论】:

  • 是的,我是个笨蛋……现在我只需要弄清楚为什么这会解析为 500 OOPS: invalid pasv_address,而 filezilla 和 firefox 都能够解决它
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-24
相关资源
最近更新 更多