-1

I've developed a .Net console application to run as a webjob under Azure App Service.

This console app is using WinSCP to transfer files from App Service Filesystem to an on-prem FTP Server.

  • The connectivity between App Service & the on-perm FTP server is Okay.

  • Most of the time the job succeeds ,the files are synced, and log files written as well.

  • Sometimes, the job fails, no files synced, and no Log is NOT being written as well.

  • The Exception that is being fired intermittently on ALL of our Azure environments (Dev, Test, Prod):

WinSCP process terminated with exit code -1073741819 (C0000005). There was no output. Response log file D:\local\Temp\wscp550C.03E988EE.tmp was not created. This could indicate lack of write permissions to the log folder or problems starting WinSCP itself.

Any Clues ?

My code snippet ..

///Session Options
            var sessionOptions = new SessionOptions
            {
                Protocol = Protocol.Sftp,
                HostName = host,
                UserName = userName,
                Password = password,
                SshHostKeyFingerprint = sshHostKeyFingerprint
            };
///Opening Session & Sync Files
                using (var session = new Session())
                {
                    var timestmp = DateTime.Now.ToString("MMddyyyyHHmmss") + ".txt";
                    session.SessionLogPath = ConfigurationManager.AppSettings["SessionLogPath"] + timestmp;
                    session.XmlLogPath = ConfigurationManager.AppSettings["XmlLogPath"] + timestmp;
                    session.XmlLogPreserve = true;
                    session.FileTransferred += FileTransferred;
                    session.Open(sessionOptions);
                    var syncResult = session.SynchronizeDirectories(SynchronizationMode.Remote, localFolder, remoteFolder, false,false);
                    syncResult.Check();
                }
mamhh
  • 85
  • 1
  • 9
  • We need [mcve]. – Martin Prikryl Nov 08 '21 at 09:15
  • it seems that the issue happens when the "WinSCP.exe" process is trying to write to app service filesystem. I think this is not allowed .. What do you think? – mamhh Nov 08 '21 at 19:09
  • You wrote before that the problem is intermittent, so is it or is it not? – Martin Prikryl Nov 08 '21 at 19:10
  • I can tell you now how the issue could be reproduced.. I've configured session.XmlLogPath & session.XmlLogPreserve to be true. Whenever session.Open(..) & session.SynchronizeDirectories(..) succeed, The log file is written. BUT, whenever an internal exception occurs in **session.Open(..)**, the above issue appears .. "Lack of Write permission" – mamhh Nov 08 '21 at 19:35
  • If WinSCP fails to even start, it obviously cannot write any log. This does not help us reproducing the problem. The *"lack of write permissions"* is just a hint, and most probably wrong in this situation. If the log can be written sometimes, it cannot be due to "write permissions". As my answer below says, the C0000005 means *"memory access violation"*. – Martin Prikryl Nov 08 '21 at 21:04
  • I've tried to run the sync process locally instead of running as Azure WebJob, and found that intermittently I catch the following exception : No supported authentication method available (Server sent: publickey) ... This system is only for Authorized Users. Access Denied !! How this is even possible? Do you think that when that exception happens it causes WinSCP to crash? – mamhh Nov 08 '21 at 22:25
  • No I do not think it is the same case. With *"WinSCP process terminated with exit code"*, the connection was most likely not even started. – Martin Prikryl Nov 09 '21 at 06:50
  • So what do you advise? and why I don't have any log generated during the occurrence of that exception? – mamhh Nov 09 '21 at 07:41
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/239028/discussion-between-user9942114-and-martin-prikryl). – mamhh Nov 09 '21 at 07:59

2 Answers2

0

WinSCP process terminated with exit code -1073741819 (C0000005). There was no output. Response log file D:\local\Temp\wscp550C.03E988EE.tmp was not created. This could indicate lack of write permissions to the log folder or problems starting WinSCP itself.

The error messages shows that you don’t give an write permission on production. Please give all write permission in Production Environment.

WinSCP could not create/write to log file that it uses to report back to the .NET assembly . Make sure your process has write permissions to the temporary folder. Alternatively, you can use (undocumented) property Session.XmlLogPath to change the log file location.

Refer here

Delliganesh Sevanesan
  • 4,146
  • 1
  • 5
  • 15
  • Doesn't C0000005 mean *"(memory) access violation"* rather than file system permissions issue? – Martin Prikryl Nov 08 '21 at 09:03
  • The exceptions happens intermittently, i.e., most of the time the job is completed successfully and sometimes it gives that exception. – mamhh Nov 08 '21 at 16:33
  • Regarding the "write" permission, I think I can not do this in App Service, since the webjob contents are being copied to run under a temp directory which I can't administrate. The only valid solution I can see, is to control the output path of such temp logs "...\wscp0DE0.0234E2B0.tmp" – mamhh Nov 08 '21 at 16:38
  • Ad "The exceptions happens intermittently" – That's quite important piece of information, and you never mentioned that in your question. – Martin Prikryl Nov 08 '21 at 17:31
  • I've configured Session.XmlLogPath to a different directory and still have the issue – mamhh Nov 08 '21 at 18:53
  • The temporary log file file location requires the write permission. Can you give a try – Delliganesh Sevanesan Nov 09 '21 at 03:37
0

C0000005 means "(memory) access violation". That probably indicates that WinSCP has crashed. It might mean a bug in WinSCP. Make sure you have the latest version. Otherwise, you better report this on WinSCP support forum, as software bugs do not really belong to Stack Overflow.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992