CentOS 上 Bamboo 中的 .Net Core SFTP 集成测试

.Net Core SFTP integration tests in Bamboo on CentOS

我正在为 SFTP 代码编写集成测试,因此我的测试使用 SFTP 服务器库来启动 SFTP 服务器侦听每个测试用例的随机端口。在 Visual Studio 2019 上为 Mac 使用 .Net Core,我的测试全部成功。当我 运行 在代理为 运行ning CentOS 的 Bamboo 构建服务器上时,出现以下错误:

05:01:09.4224  ERROR Failed to connect to localhost System.Net.Sockets.SocketException (111): Connection refused
15-Aug-2020 05:01:10        at Renci.SshNet.Abstractions.SocketAbstraction.Connect(IPEndPoint remoteEndpoint, TimeSpan connectTimeout)
15-Aug-2020 05:01:10        at Renci.SshNet.Session.SocketConnect(String host, Int32 port)
15-Aug-2020 05:01:10        at Renci.SshNet.Session.Connect()
15-Aug-2020 05:01:10        at Renci.SshNet.BaseClient.CreateAndConnectSession()
15-Aug-2020 05:01:10        at Renci.SshNet.BaseClient.Connect()

日志表明 SFTP 服务器正在启动并正确绑定到随机端口,所以我不确定为什么到 localhost 的出站连接会失败。

localhost 无效,但 127.0.0.1 有效。显然构建代理没有配置 localhost 名称。