[英]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.