Network error: Software caused connection abort

Advertisement

Aslam
Guest

Network error: Software caused connection abort

Hi,
I am trying send files from one machine to other through SFTP, but always getting error through the code, while I am sending the file from WinSCP GUI then it always successfully sent. Only issue through the .NET code. Below is the code I have done.
var sessionOptions = new SessionOptions();
sessionOptions.Protocol = Protocol.Sftp;
sessionOptions.HostName = pHostName;  
sessionOptions.UserName = pUserName;
sessionOptions.Password = pPassword;
sessionOptions.PortNumber = pPortNumber;
sessionOptions.Timeout = TimeSpan.FromSeconds(600); 
sessionOptions.SshHostKeyFingerprint = pHostKey;    
using (var session = new Session())
{
    // Connect
    try
    {
        session.DisableVersionCheck = true;
    }
    catch (Exception ex)
    {
    }
    finally
    {
        GC.Collect();
    }
 
    session.DebugLogLevel = 1;
    session.DebugLogPath = @"D:\winscp_log\debug\debug.log";
 
    session.Open(sessionOptions);
    logwriter.WriteLine(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "****************WinSCP Session established");
 
    var transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Binary;
    transferOptions.OverwriteMode = OverwriteMode.Overwrite;
 
    TransferOperationResult transferResult;
    if (pCloudTransfer == true)
    {
        logwriter.WriteLine(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "****************Inside cloud transfer flag.");
 
        transferResult = session.PutFiles(pInputFolderName + @"\*.csv", "/" + pCUploadFolder + "/", true, transferOptions);
    }
    else
    {
        logwriter.WriteLine(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "****************Inside dubai server flag.");
 
        transferResult = session.PutFiles(pInputFolderName + @"\*.csv", "/" + pDUploadFolder + "/", true, transferOptions);
    }
 
    // Throw on any error
    transferResult.Check();
 
    // Print results
    foreach (TransferEventArgs transfer in transferResult.Transfers)
    {
        Console.WriteLine(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "****************Upload of " + transfer.FileName + " succeeded");
        logwriter.WriteLine(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") + "****************Upload of " + transfer.FileName + " succeeded");
    }
}
Description: I have added debug file with the attachment. kindly help me I am getting the issue since many days.

Reply with quote

Advertisement

Guest

Hi Martin,

Thanks for reply,
Here I have attached session log, I keep active process for more than 10 minutes. then I stopped session and then session log generated.

Please have a look in session log file.

Reply with quote

Advertisement

Guest

Hi Martin,

Can you please let me know from where I can get normal complete log file from .NET code?

Guide me here please.
Thanks,

Reply with quote

martin
Site Admin
martin avatar

For the complete log, simply do not edit it before posting.
For the Normal logging level, remove the session.DebugLogLevel = 1;.

Reply with quote

Guest

Hi Martin,

Sorry for delay, actually I am not getting notification when you are posting comment so.
Anyways, I have attached session log from GUI with normal level.

And attached debug and session log, after removing session.DebugLogLevel = 1;

Please check 3 files I have attached.
Thanks,

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum