Wednesday, May 14, 2014

FTPWebRequest TimeOut Issue

I am doing an upgrade on the app host on ASP.Net 2.0 and running on .Net framework 2.0 to

host in windows server 2012 running ASP.Net 4.0 engine and 4.5 .Net Framework

however one of the upload page was hanged for period time, then throw an exception

Exception information:
    Exception type: WebException
    Exception message: The operation has timed out.
   at ASP.fileupload_aspx.submit(Object Sender, EventArgs e) in C:\MyAppFolder\FileUpload.aspx:line 129
   at System.Web.UI.HtmlControls.HtmlInputButton.OnServerClick(EventArgs e)
   at System.Web.UI.HtmlControls.HtmlInputButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.HtmlControls.HtmlInputButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)




I went back to the old server to run the same application. the upload process was completed very quick.

the root cause of this issue is that connection can't be established

http://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest.usepassive.aspx 

stated that "Setting the UsePassive property to true sends the "PASV" command to the server. This command requests the server to listen on a data port and to wait for a connection rather than initiate one upon receipt of a transfer command."

My old code that caused the upload in long run

 ftp.UsePassive = false

my fix to allow the client initiates the connection

 ftp.UsePassive =true





No comments:

Post a Comment