Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

FTP Send File Error "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."

$
0
0

Hello there,

For the past few days we are running into a problem when using FTP Task in SSIS

Cannot able to send files to a FTP Server, while sending a file we receive an error "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."

After lots of searching, some suggest that it is not an error but an information as the file is not present in server. We tried switching to a different ftp server and the same code is fine and sends files without any problems.

So I decided to switch FTP Task to Script Task where I do upload using WebClient. Even after handling with FtpStatusCode.ActionNotTakenFileUnavailable, cannot able to send files (FTP Upload). Here is the code excerpt

            try
            {
                var files = new List<string>();
                foreach (var conn in Dts.Connections)
                {
                    if (conn.CreationName == "FLATFILE")
                    {
                        files.Add(conn.ConnectionString);
                        using (WebClient client = new WebClient())
                        {
                            //client.UploadDataCompleted
                            client.Credentials = new NetworkCredential("xxx", "xxx");
                            Uri input = new Uri(Path.Combine( @"ftp://xxx/Incoming/", Path.GetFileName(conn.ConnectionString)));
                            try
                            {
                                client.UploadFile(input, "STOR", conn.ConnectionString);
                            }
                            catch (WebException we)
                            {
                                var resp = (FtpWebResponse)we.Response;
                                if (resp.StatusCode != FtpStatusCode.ActionNotTakenFileUnavailable) throw;
                            }

                        }
                        //break;
                    }
                }
                Dts.Variables["User::FtpFilesCollection"].Value = files;
                Dts.TaskResult = (int)ScriptResults.Success;

            }
            catch (System.Exception e)
            {
                Dts.Events.FireError(0, "Shops", e.ToString(), string.Empty, 0);
            }

This is the WebException I receive after the WebClient.UploadFile

-{"The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."}System.Net.WebException
-[System.Net.FtpWebResponse]{System.Net.FtpWebResponse}System.Net.FtpWebResponse
+base {System.Net.FtpWebResponse}System.Net.WebResponse {System.Net.FtpWebResponse}
BannerMessage"220 (vsFTPd 3.0.2)\r\n"string
ContentLength 0long
ExitMessage""string
+Headers {
}System.Net.WebHeaderCollection
+LastModified{01/01/0001 00:00:00}System.DateTime
+ResponseUri{ftp://xxxx/Incoming/NEGSERV2020031719.chk} System.Uri
StatusCode ActionNotTakenFileUnavailableSystem.Net.FtpStatusCode
StatusDescription"550 Permission denied.\r\n" string
SupportsHeaderstruebool
WelcomeMessage"230 Login successful.\r\n" string

I really appreciate your suggestions and tips

Stay safe and well,

Holy



Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>