[英]Unable to connect to a remote SFTP server from a Free Azure app service
我有一个在本地运行良好的Asp.Net Core网站,我能够连接到SFTP服务器并获取文件。 但是,一旦我部署到Azure应用服务,它将试图建立连接只是超时。
我得到的例外是
2019-09-03 10:37:28.7942||ERROR|ExclusiveCard.Services.SFTPProvider|Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at ExclusiveCard.Services.SFTPProvider.TestConnection() in SFTPProvider.cs:line 237 Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
我使用的代码是
SftpClient sftpClient = null;
try
{
sftpClient = new SftpClient("servaer", 2222, "ExclusiveDev", "password");
}
catch (Renci.SshNet.Common.SshOperationTimeoutException ex)
{
Console.WriteLine(ex.ToString());
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
我使用过程序包Renci.SshNet.Async version =“ 1.4.0。此代码在本地完全正常,但是在部署时在Azure App Service上失败。
任何帮助,不胜感激。 谢谢。
听起来您已经将ASP.NET Core应用程序部署到Windows上的Azure App Service,并且它试图从Windows上的Azure App Service连接远程SFTP服务器。
因此,我确定它永远不会在Windows系统的Azure App Service上正常工作,因为存在网络限制,如下所示, Use of Raw Sockets
Azure Web App沙盒Use of Raw Sockets
来限制套接字连接的建立。
因此,我建议您可以尝试重建您的应用程序,以将其部署到Linux上的Azure App Service 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.