OpenWrite not working in Azure

Apr 27, 2014 at 5:56 PM
Edited Apr 27, 2014 at 6:00 PM
Hello,
I'm working with System.Net.FtpClient and I'm have some problems to run code in Azure.

In my personal PC it's working good. When I'm running same code in my Azure VPS - it's not working.

This is the log from Azure server:
220 (vsFTPd 3.0.2)
USER *******
331 Please specify the password.
PASS <omitted>
230 Login successful.
FEAT
211-Features:
 EPRT
 MDTM
 REST STREAM
 SIZE
 TVFS
 UTF8
211 End
Text encoding: System.Text.UTF8Encoding
PWD
257 "/home/*******"
CWD /home/*********/2
250 Directory successfully changed.
CWD /home/*******
250 Directory successfully changed.
PWD
257 "/home/*******"
CWD /home/****************/13137
250 Directory successfully changed.
CWD /home/*******
250 Directory successfully changed.
TYPE I
200 Switching to Binary mode.
SIZE /home/********/content.txt
550 Could not get file size.
EPRT |1|********|57171|
500 Illegal EPRT command.  # <--------------------------------------BOOM
QUIT
221 Goodbye.
Disposing FtpClient object...
Disposing FtpSocketStream...
Same application, in my PC (Working GOOD):
220 (vsFTPd 3.0.2)
USER *******
331 Please specify the password.
PASS <omitted>
230 Login successful.
FEAT
211-Features:
 EPRT
 MDTM
 REST STREAM
 SIZE
 TVFS
 UTF8
211 End
Text encoding: System.Text.UTF8Encoding
PWD
257 "/home/***********"
CWD /home/********/2
250 Directory successfully changed.
CWD /home/*******
250 Directory successfully changed.
PWD
257 "/home/**********"
CWD /home/************************/13139
250 Directory successfully changed.
CWD /home/***********
250 Directory successfully changed.
TYPE I
200 Switching to Binary mode.
SIZE /home/**************/content.txt
550 Could not get file size.
EPRT |1|****************|51391|
200 EPRT command successful. Consider using EPSV.
STOR /home/**********************/content.txt
150 Ok to send data.
Disposing FtpSocketStream...
226 Transfer complete.
TYPE I
200 Switching to Binary mode.
SIZE /home/************/links.txt
550 Could not get file size.
EPRT |1|**************|51392|
200 EPRT command successful. Consider using EPSV.
STOR /home/****************/links.txt
150 Ok to send data.
Disposing FtpSocketStream...
226 Transfer complete.
QUIT
221 Goodbye.
Disposing FtpClient object...
Disposing FtpSocketStream...
Disposing FtpClient object...
Disposing FtpSocketStream...
Disposing FtpSocketStream...
My code:
Client = new FtpClient()
            {
                Host = FTP_HOST,
                Credentials = new NetworkCredential(FTP_USER, FTP_PASS),
                EnableThreadSafeDataConnections = false,
                DataConnectionType = FtpDataConnectionType.EPRT,
                Encoding = Encoding.UTF8,
            };
// ... 
using (Stream fs = this.Client.OpenWrite(contentPath))
            {
                byte[] arr = StringArrayToByteArray(parser.Contents);
                try
                {
                    fs.Write(arr, 0, arr.Length);
                }
                catch (Exception ex)
                {
                }
            }
I'm have no clue why it's not working in Azure server.

Thank you for support.
Coordinator
Apr 27, 2014 at 5:59 PM
Change the data channel type to passive. The sever doesn't support epsv which is extendedpassive.

Sent from my iPhone

Apr 27, 2014 at 6:12 PM
Edited Apr 27, 2014 at 6:13 PM
The server not supporting any kind of pasive (pasive or extended pasive).

So, I'm trying to work in "EPRT" mode, which is supported:
211-Features:
 EPRT <--------------------------- see here
 MDTM
 REST STREAM
 SIZE
 TVFS
 UTF8
From log:
500 Illegal EPRT command.
I'm have no clue why running the code in Azure it's being failed.
From trace log, it's seems to me that same command sent in both cases. In azure its failed and in my PC its working.
Coordinator
Apr 27, 2014 at 8:19 PM
Does EPRT work with any other client connecting to this server? What about just plain old PORT? Looks like it may just be a bug in vsftpd as here's a thread with curl having the same issue:

EPRT does not work with vsftpd

I don't know what 500 Illegal EPRT command is supposed to mean; maybe there's more information in the server logs? It's really hard to say what's going wrong without knowing more information.
Coordinator
Apr 27, 2014 at 8:24 PM
Also off topic, but there's no reason to explicitly set the text encoding to UTF8. System.Net.FtpClient does it automatically if the server software supports UTF8. The only reason to manually change the encoding are special edge cases where some other encoding besides ASCII or UTF8 are to be used.

Any how; I'd check server logs and compare the two server configs to see what's different if anything. Is it sending and IPV6 address to the server when it should be sending IPV4 or vice versa? The 1 in the EPRT command means IPV4 but you've taken that information out. There's not reason to share the address just confirm that an IPV4 address is indeed being sent in the EPRT command.