EPSV is not working when trying to connect to some FTP Server (sorry, we don't know any details about this server).
Here is the error:
"System.Net.FtpClient.FtpException : Failed to get the EPSV port from: Entering Extended Passive Mode (!!!51603!
). at System.Net.FtpClient.FtpClient.OpenPassiveDataStream(" [...]
I think that the line 1087 of the function "OpenPassiveDataStream" from the file "FtpClient.cs" is incorrect :
m = Regex.Match(reply.Message, @"\(\|\|\|(?<port>\d+)\|\)");
So the client is expecting the "|" character
, and the server we are facing
is responding with the "!" character
This "!" seems to be allowed by the
, which indeed recommands the "|", but allows any ASCII separator from 33 to 126.
Reference: RFC 2428, search for "The EPSV Command" and also "delimiter"
I don't know much about Regex, but going to modify it to accept 33 to 126 delimiters.
Please correct me if i'm wrong somewhere.
Modified 1087 line to accept 33-126 delimiters in passive mode :
m = Regex.Match(reply.Message, @"\([\x21-\x7E][\x21-\x7E][\x21-\x7E](?<port>\d+)[\x21-\x7E]\)");