Click to See Complete Forum and Search --> : FtpWebRequest doesn't work in parallel threads


Elina Lazebnik
June 22nd, 2009, 03:18 AM
I work with C# 2.0 VC2008.
I use a number of Background Workers for open multiply FTP Connections to same FTP Server. The connections are in an Active FTP Mode.
:thumbd: When I start 2 connections together, the first one is working properly and the second stops after the connection has been established good and waits for Data ( get data only after the first connection closed ).
:thumb: When I run two applications with one FTP Session for each, I haven't any problem.


This is a part of request code :

// sPath = "ftp://user_name:user_pass@server_address:21//path")
FtpWebRequest request = (FtpWebRequest)WebRequest.Create( sPath );
request.UsePassive = false;
request.Proxy = null;
request.Method = WebRequestMethods.Ftp.GetFileSize;

this.curFTPState.FileName = Path.Combine(sPathTo, filename);
this.curFTPState.FTPMethod = WebRequestMethods.Ftp.GetFileSize;
this.curFTPState.Request = request;


// Start the asynchronous request.
IAsyncResult result = (IAsyncResult)request.BeginGetResponse(new AsyncCallback(RespCallback), curFTPState);

Mutant_Fruit
June 22nd, 2009, 01:46 PM
Does the FTP server in question allow multiple connections from the same IP?

Elina Lazebnik
June 23rd, 2009, 12:52 AM
Yes, actually same application, has run twice with one connection each, is connecting and getting data perfect. On specific server I can open only 2 connections simultaneously, because system limitation.