0 votes
by (130 points)

Hi!

Is anyone getting the say error what I am getting,
I have few servers And upload works fine for all except one server. The once it is getting failed is returning the following error message.

Rebex.Net.FtpException: Socket error 10049. ---> Rebex.Net.ProxySocketException: Socket error 10049. ---> Rebex.Net.ProxySocketException: Socket error 10049. ---> System.Net.Sockets.SocketException: The requested address is not valid in its context 0.0.0.0:12085
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at Rebex.Net.VV.WC(String A, IPAddress B, Int32 C)
--- End of inner exception stack trace ---
at Rebex.Net.VV.WC(String A, IPAddress B, Int32 C)
--- End of inner exception stack trace ---
at Rebex.Net.VV.VC(IAsyncResult A, String B)
at Rebex.Net.VV.QB(IAsyncResult A)
at Rebex.Net.ProxySocket.EndConnect(IAsyncResult asyncResult)
at Rebex.Net.ZJ.KC(IPEndPoint A)
--- End of inner exception stack trace ---
at Rebex.Net.ZJ.KC(IPEndPoint A)
at Rebex.Net.Ftp.NM(String A, Boolean B, ZJ C, EH D, Int64 E, FtpTransferState H)
at Rebex.Net.Ftp.IO(String A, String B, Stream C, Int64 D, Int64 E, EH H)
at Rebex.Net.Ftp.PutFile(Stream sourceStream, String remotePath)

1 Answer

+1 vote
by (144k points)

Which version of Rebex FTP do you use? From the stack trace, it looks like your Rebex FTP is from 2015 or earlier. In 2017, one of our customers encountered an FTP server that erroneously returned 0.0.0.0 in response to PASV command, and that they have been getting socket 10049 errors as a result. That corresponds to the behavior you report.

We added a workaround for this server-side bug in Rebex FTP/SSL 2017 R6.1:

FTP: Added workaround for FTP servers that announce their IP as 0.0.0.0.

So upgrading to Rebex FTP/SSL 2017 R6.1 or later should resolve the issue.
Alternatively, report the issue to the server maintainer or vendor and ask them to fix it.

by (130 points)
edited by
Hi! Lukas,

Thank you for the quick response, these are the versions currently I am using in my application.
Rebex Versions(DLL)

* Rebex.Common - 2.0.5298.0

* Rebex.FileTransfer - 4.0.5298.0

* Rebex.Ftp - 4.0.5298.0

* Rebex.Networking - 3.0.5298.0

* Rebex.Sftp - 3.0.5298.0

I will update to latest nuget package and get back to you,

once again thank you
by (144k points)
Hi, that's almost 8 years old: https://www.rebex.net/ftp-ssl.net/history.aspx#5298
If you have any trouble upgrading, don't hesitate to contact us for assistance.
by (130 points)
edited by
Hi! Lukas Pokorny,

Yes it is pretty old, I will get back to you any issues.
Thank you
by (130 points)
edited by
Hi! Lukas Pokorny,

After updating the package also getting the same Error

```FileSystemInput job failed : Rebex.Net.FtpException: Socket error 10049.
---> Rebex.Net.ProxySocketException: Socket error 10049.
---> Rebex.Net.ProxySocketException: Socket error 10049.
---> System.Net.Sockets.SocketException: The requested address is not valid in its context 0.0.0.0:12085     
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)     
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)     at Rebex.Net.VV.WC(String A, IPAddress B, Int32 C)     
--- End of inner exception stack trace ---     at Rebex.Net.VV.WC(String A, IPAddress B, Int32 C)     
--- End of inner exception stack trace ---     at Rebex.Net.VV.VC(IAsyncResult A, String B)   
at Rebex.Net.VV.QB(IAsyncResult A)     at Rebex.Net.ProxySocket.EndConnect(IAsyncResult asyncResult)     
at Rebex.Net.ZJ.KC(IPEndPoint A)     
--- End of inner exception stack trace ---     
at Rebex.Net.ZJ.KC(IPEndPoint A)     
at Rebex.Net.Ftp.NM(String A, Boolean B, ZJ C, EH D, Int64 E, FtpTransferState H)     
at Rebex.Net.Ftp.IO(String A, String B, Stream C, Int64 D, Int64 E, EH H)     
at Rebex.Net.Ftp.PutFile(Stream sourceStream, String remotePath)     ```
by (144k points)
Hi, please use Ftp object's LogWriter property (as described at https://www.rebex.net/kb/logging/) to create a debug log, and either post it here or mail it to support@rebex.net for analysis. That should make it possible to tell what is going on.
by (130 points)
edited by
Hi Lukas,
Thanks alot for the response. this is the latest Error

FileSystemInput job failed : Rebex.Net.FtpException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond <IPAddress>:12077
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at fkshw.gyomj.Connect(EndPoint remoteEP)
   at fkshw.xdjik.jbsor(IPEndPoint p0)
   at fkshw.jflij.lndeu(EndPoint p0)
   at Rebex.Net.ProxySocket.Connect(EndPoint remoteEP)
   --- End of inner exception stack trace ---
   at Rebex.Net.ProxySocket.Connect(EndPoint remoteEP)
   at fkshw.fwdvg.hxcni(IPEndPoint p0)
   --- End of inner exception stack trace ---
   at fkshw.fwdvg.hxcni(IPEndPoint p0)
   at Rebex.Net.Ftp.ailva(String p0, Boolean p1, fwdvg p2, hsmco p3, Int64 p4, FtpTransferState p5)
   at Rebex.Net.Ftp.heqhw(String p0, String p1, Stream p2, Int64 p3, Int64 p4, hsmco p5)
   at Rebex.Net.Ftp.PutFile(Stream sourceStream, String remotePath)
   at Bes.Framework.BL.Utilities.BesFTP.UploadFile(Byte[] fileContents, String remotePath)
   at Bes.CORE.BL.FileSystemController.ProcessOutboundService(FileSystemService service).

I am sorry I am unable to write to a log file , but I am writing  the Error to the database
by (70.2k points)
You can still write the communication log (with the error) to DB like this:

   var client = new Ftp();
   client.LogWriter = new StringLogWriter();

    try
    {
        client.PutFile("...", "...");
    }
    catch (Exception ex)
    {
        string error = client.LogWriter.ToString() + ex.ToString();
        // write error to DB
        // ...
    }

The StringLogWriter class looks like this:

    public class StringLogWriter : LogWriterBase
    {
        private readonly StringBuilder _logBuilder;

        public StringLogWriter(LogLevel level = LogLevel.Debug)
        {
            _logBuilder = new StringBuilder();
            Level = level;
        }

        protected override void WriteMessage(string message)
        {
            _logBuilder.Append(message);
        }

        public override string ToString()
        {
            return _logBuilder.ToString();
        }
    }
by (130 points)
FileSystemInput job failed : System.Exception: 2022-07-12 07:57:17.732 INFO Ftp(51)[25] Info: Connecting to ftp.client.com:21 using Ftp.
2022-07-12 07:57:17.732 INFO Ftp(51)[25] Info: Assembly: Rebex.Ftp R6.4 for .NET 4.6-4.8
2022-07-12 07:57:17.732 INFO Ftp(51)[25] Info: Platform: Windows 6.2.9200 64-bit; CLR: 4.0.30319.42000
2022-07-12 07:57:17.732 DEBUG Ftp(51)[25] Info: Culture: en; Windows-1252
2022-07-12 07:57:17.732 INFO Ftp(51)[25] Info: Using proxy none.
2022-07-12 07:57:17.732 DEBUG Ftp(51)[25] Proxy: Resolving 'ftp.client.com'.
2022-07-12 07:57:17.748 DEBUG Ftp(51)[25] Proxy: Connecting to <IP Address>:21 (no proxy).
2022-07-12 07:57:17.763 DEBUG Ftp(51)[25] Proxy: Connection established.
2022-07-12 07:57:17.763 DEBUG Ftp(51)[25] Info: Connection succeeded.
2022-07-12 07:57:17.779 INFO Ftp(51)[25] Response: 220 Welcome to client FTP service.
2022-07-12 07:57:17.779 INFO Ftp(51)[25] Command: USER dms
2022-07-12 07:57:17.795 INFO Ftp(51)[25] Response: 331 Please specify the password.
2022-07-12 07:57:17.795 INFO Ftp(51)[25] Command: PASS **********
2022-07-12 07:57:17.826 INFO Ftp(51)[25] Response: 230 Login successful.
2022-07-12 07:57:17.826 INFO Ftp(51)[25] Command: FEAT
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Response: 211-Features:
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Response:  EPRT
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Response:  EPSV
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Response:  MDTM
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Response:  PASV
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Response:  REST STREAM
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Response:  SIZE
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Response:  TVFS
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Response: 211 End
2022-07-12 07:57:17.841 INFO Ftp(51)[25] Command: TYPE I
2022-07-12 07:57:17.857 INFO Ftp(51)[25] Response: 200 Switching to Binary mode.
2022-07-12 07:57:17.857 INFO Ftp(51)[25] Command: SIZE .
2022-07-12 07:57:17.873 INFO Ftp(51)[25] Response: 550 Could not get file size.
2022-07-12 07:57:17.873 INFO Ftp(51)[25] Command: SIZE /inbox/test/nem12#dfd5bb274c0a45fa92e647f027acc8cb#GLOBALM#SSBIDFTP.CSV
2022-07-12 07:57:17.888 INFO Ftp(51)[25] Response: 550 Could not get file size.
2022-07-12 07:57:17.888 DEBUG Ftp(51)[25] Info: Starting data transfer.
2022-07-12 07:57:17.888 INFO Ftp(51)[25] Command: PASV
2022-07-12 07:57:17.904 INFO Ftp(51)[25] Response: 227 Entering Passive Mode (0,0,0,0,47,49).
2022-07-12 07:57:17.904 DEBUG Ftp(51)[25] Info: Establishing data connection to 'ftp.client.com'.
2022-07-12 07:57:17.904 DEBUG Ftp(51)[25] Proxy: Resolving 'ftp.client.com'.
2022-07-12 07:57:17.904 DEBUG Ftp(51)[25] Proxy: Connecting to <IP Address>:12081 (no proxy).
2022-07-12 07:57:38.921 DEBUG Ftp(51)[25] Info: Error while starting data transfer: Rebex.Net.FtpException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond <IP Address>:12081
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at fkshw.gyomj.Connect(EndPoint remoteEP)
   at fkshw.xdjik.jbsor(IPEndPoint p0)
   at fkshw.jflij.lndeu(EndPoint p0)
   at Rebex.Net.ProxySocket.Connect(EndPoint remoteEP)
   --- End of inner exception stack trace ---
   at Rebex.Net.ProxySocket.Connect(EndPoint remoteEP)
   at fkshw.fwdvg.hxcni(IPEndPoint p0)
   --- End of inner exception stack trace ---
   at fkshw.fwdvg.hxcni(IPEndPoint p0)
   at Rebex.Net.Ftp.ailva(String p0, Boolean p1, fwdvg p2, hsmco p3, Int64 p4, FtpTransferState p5)
2022-07-12 07:57:38.921 DEBUG Ftp(51)[25] Info: Error while initializing data connection.
2022-07-12 07:57:38.921 ERROR Ftp(51)[25] Info: Rebex.Net.FtpException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond <IP Address>:12081
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at fkshw.gyomj.Connect(EndPoint remoteEP)
   at fkshw.xdjik.jbsor(IPEndPoint p0)
   at fkshw.jflij.lndeu(EndPoint p0)
   at Rebex.Net.ProxySocket.Connect(EndPoint remoteEP)
   --- End of inner exception stack trace ---
   at Rebex.Net.ProxySocket.Connect(EndPoint remoteEP)
   at fkshw.fwdvg.hxcni(IPEndPoint p0)
   --- End of inner exception stack trace ---
   at fkshw.fwdvg.hxcni(IPEndPoint p0)
   at Rebex.Net.Ftp.ailva(String p0, Boolean p1, fwdvg p2, hsmco p3, Int64 p4, FtpTransferState p5)
   at Rebex.Net.Ftp.heqhw(String p0, String p1, Stream p2, Int64 p3, Int64 p4, hsmco p5)
Rebex.Net.FtpException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
---> Rebex.Net.ProxySocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond <IP Address>:12081
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at fkshw.gyomj.Connect(EndPoint remoteEP)
   at fkshw.xdjik.jbsor(IPEndPoint p0)
   at fkshw.jflij.lndeu(EndPoint p0)
   at Rebex.Net.ProxySocket.Connect(EndPoint remoteEP)
   --- End of inner exception stack trace ---
   at Rebex.Net.ProxySocket.Connect(EndPoint remoteEP)
   at fkshw.fwdvg.hxcni(IPEndPoint p0)
   --- End of inner exception stack trace ---
   at fkshw.fwdvg.hxcni(IPEndPoint p0)
   at Rebex.Net.Ftp.ailva(String p0, Boolean p1, fwdvg p2, hsmco p3, Int64 p4, FtpTransferState p5)
   at Rebex.Net.Ftp.heqhw(String p0, String p1, Stream p2, Int64 p3, Int64 p4, hsmco p5)
   at Rebex.Net.Ftp.PutFile(Stream sourceStream, String remotePath)
by (70.2k points)
Thank you for the log file. From the point of client, the communication looks correct.
It is very probable that the issue is caused by a server firewall setting. When a FTP data connection needs to be established, the connection is not allowed at the firewall, resulting in the observed SocketException.

Possible solutions:
1. Ask your network administrator to set up server firewall and the FTP server appropriately. You can typically allow a range of ports for FTP data connections at the server - then allow the same range on the firewall. For example range of ports 10001-19999.
2. Instead using FTP in passive mode, try to use FTP in active mode. However, it is even more prone to firewall settings. In active mode, the FTP server connects to the client, so the server firewall must allow outgoing connections (to specific port range) and the client firewall must allow incoming connections (to specific port range) - the port range must be defined at the FTP client (see Ftp.DataPortRange).
3. Instead using legacy FTP protocol, use more firewall friendly protocol, such as SFTP. It does not require to establish multiple connections.

Are you able to upload files to the FTP server from the same client machine using a 3rd party FTP client (such as WinSCP or FileZilla)?
by (130 points)
Are you able to upload files to the FTP server from the same client machine using a 3rd party FTP client (such as WinSCP or FileZilla)?  Yes

Possible solutions: Need to look into it, I will get back to you
by (130 points)
it worked with Passive = false (ActiveMode)  and
FTP.Settings.IgnorePassiveModeAddress = true /false (any)
by (70.2k points)
Thank you for the info.

The IgnorePassiveModeAddress option has effect in FTP passive mode only (it has no meaning when using FTP active mode).

As I described above, the issue with FTP passive mode is very probably caused by a firewall along the way to the server (I don't suspect the FTP server itself). And you are lucky, that the FTP active mode is working for you. If you want to investigate the issue further, you have to ask your FTP server/network administrator. We cannot tell you more from the client side - we can only state that the connections from client to ports reported by the FTP server in passive mode are blocked.
...