I get exactly the same stack trace in an SSIS package trying FTP over SSL. It works fine without SSL, but as soon as I enable SSL, it explodes.
System.Net.WebException: System error. ---> System.Net.InternalException: System error. at System.Net.PooledStream.PrePush(Object expectedOwner) at System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse) at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage) at System.Net.FtpWebRequest.SyncRequestCallback(Object obj) at System.IO.Stream.Close() at System.Net.ConnectionPool.Destroy(PooledStream pooledStream) at System.Net.ConnectionPool.PutConnection(PooledStream pooledStream, Object owningObject, Int32 creationTimeout, Boolean canReuse) at System.Net.FtpWebRequest.AttemptedRecovery(Exception e) at System.Net.FtpWebRequest.SubmitRequest(Boolean async) --- End of inner exception stack trace --- at System.Net.FtpWebRequest.CheckError() at System.Net.FtpWebRequest.GetRequestStream() at ST_0ff7348de65a468bb358ab0206e3721f.ScriptMain.Main() in c:\Users\Stephens\AppData\Local\Temp\Vsta\e664c8a71bb647ff9e9dc6ac32d7b615\ScriptMain.cs:line 155 at System.Net.FtpWebRequest.CheckError() at System.Net.FtpWebRequest.GetRequestStream() at ST_0ff7348de65a468bb358ab0206e3721f.ScriptMain.Main() in c:\Users\Stephens\AppData\Local\Temp\Vsta\e664c8a71bb647ff9e9dc6ac32d7b615\ScriptMain.cs:line 155
Since the error is so general, I decided to look at the .NET source to find out if I can catch the key to the question of what is happening. If you are here:
http://labs.developerfusion.co.uk/SourceViewer/browse.aspx?assembly=SSCLI&namespace=System.Net# {% 22pageClientState% 22% 3A% 22type-2844% 2Ccsharp% 22}
and go to line 281, you will see the definition for the inner void PrePush (object expectedOwner), which is what is executed when the exception occurs. Here's what it looks like:
internal void PrePush(object expectedOwner) { lock (this) {
In the end, I found that FtpWebRequest only supports explicit FTP (port 21) and not implicit FTP (port 990). This was finally stated here:
Does .NET support FtpWebRequest both implicit (FTPS) and explicit (FTPES)?
Anyway, in my case it was a firewall issue. Initially, we configured for implicit FTP, which was ports 989, 990, 49152-65535 (for each vendor technical staff). I checked with my network guy, and we opened ports 20, 21, 989, 990 and 40000-655535 for explicit, and now everything worked like a champion.
However, in your case, it seems that you are initiating a connection pool. Here is a good post on this:
How to increase the performance of FtpWebRequest?
You might want to take a look at how to configure the connection pool and see if you can make some progress. Hope this helps!
Hello,
Stewart