.NET library – error while running scheduled task

Advertisement

lakovacs56
Joined:
Posts:
1

.NET library – error while running scheduled task

Hello Everyone,

My little .NET application does simple tasks: downloads files via FTP or SFTP using WInSCP .NET library (5.0.9, build 2578).
When I schedule this on a Windows Server 2008 R2, sometimes I get this error message:
WinSCP process terminated with exit code 3 and output "", without creating a log file.
Running exactly the same task (same user, same commands) manually there is no error.
After restarting the server everything works fine.

First of all I'd like to know more about 'exit code 3'.
Where can be found detailed information?

Thanks, Lazslo

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: .NET library - error while running scheduled task

Can any one of you try to upgrade to 5.1.4? If that does not help, please set Session.DebugLogPath and email me the log.

You will find my address (if you log in) in my forum profile.

Reply with quote

calin
Guest

I still encounter the issue on a windows service

Hi,

I still encounter this issue having same error message:
WinSCP process terminated with exit code 3 and output "", without creating a log file.
WinSCP 5.1.0
OS: Windows Server 2008 r2 Enterprise, sp1

WinSCP is running in a Windows Service on the above OS. The job run well until 00:30 CET, 27.02.2013. Since then the WinSCP job fails to open session throwing same exception no matter what server is trying to connect to(I am currently using it for 3 different SFTP connections).

The Windows Service is installed on two similar machines, but I get this error only on one of them.

Best regards!

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: I still encounter the issue on a windows service

@calin: Please upgrade to 5.1.4. If that does not help set Session.DebugLogPath and email me the log.
You will find my address (if you log in) in my forum profile.

Reply with quote

boxpavel
Joined:
Posts:
1
Location:
Moscow

Re: I still encounter the issue on a windows service

I have a similar problem OS server 2008 R2, after upgrade to 5.1.4
debug log:
[2013-03-03 08:43:06.619Z] [0003]   Session.SessionOptionsToOpenArguments leaving
[2013-03-03 08:43:06.619Z] [0003]   Command: [open -hostkey="ssh-rsa 2048 f3:39:87:14:b1:64:35:ef:59:3d:8e:8e:90:f9:65:cc" -privatekey="C:\Scripts\Service\private.ppk" -timeout=15 "sftp://abs@10.110.69.101:4268"]
[2013-03-03 08:43:06.639Z] [0003]   ExeSessionProcess.ExecuteCommand entering
[2013-03-03 08:43:06.639Z] [0003]   ExeSessionProcess.ExecuteCommand leaving
[2013-03-03 08:43:06.691Z] [0003]   Process 58356 exited with exit code 3
[2013-03-03 08:43:06.692Z] [0003]   Exception: WinSCP.SessionLocalException: WinSCP process terminated with exit code 3 and output "", without creating a log file.
[2013-03-03 08:43:06.694Z] [0003]   Exception: WinSCP.SessionLocalException: WinSCP process terminated with exit code 3 and output "", without creating a log file.
   at WinSCP.Session.Open(SessionOptions sessionOptions)
[2013-03-03 08:43:06.695Z] [0003]   Session.Cleanup entering
[2013-03-03 08:43:06.695Z] [0003]     Terminating process
[2013-03-03 08:43:06.695Z] [0003]     Command: [exit]

Reply with quote

sorcer1fr
Guest

same problem

Hello,

i have the same message :
[2013-03-05 09:45:49.900Z] [0001]   Exception: WinSCP.SessionLocalException: WinSCP process terminated with exit code 3 and output "", without creating a log file.

Reply with quote

Advertisement

suchanv
Joined:
Posts:
3
Location:
Praha

Error with exit code 3

Hi,
I have the same message:
WinSCP.SessionLocalException: WinSCP process terminated with exit code 3 and output "", without creating a log file.
WinSCP version 5.1.4 with WinSCP.dll version 1.0.5.2937
On Windows Server 2008 R2 64 bit

My C# app is 32 bit. When it runs as console all is OK. When it runs as service fails with this error message.

Please help

Reply with quote

OmmyT
Joined:
Posts:
2

Re: Error with exit code 3

I recently ran into the same issue with WinSCP 5.1.1 - any news about that?

(scheduled task on W2K8R2 -> WinSCP.SessionLocalException: WinSCP process terminated with exit code 3 and output "", without creating a log file -> WinSCP.Session.Open(SessionOptions sessionOptions))

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: Error with exit code 3

@OmmyT: Please download Process Monitor from:
https://learn.microsoft.com/en-us/sysinternals/downloads/procmon

When you run it, it will ask you to enter filter (if not, use filter toolbar button).
Select "Process Name", "contains", "winscp" => Add => Ok.

Then make the scheduler run WinSCP.

Hopefully some records about the start show up.

The go to File > Save, select "Events displayed using current filter" and PML format (both should be default).

Email me the .pml file.

Reply with quote

Advertisement

OmmyT
Joined:
Posts:
2

Re: Error with exit code 3

Hi Martin,

thanks for your answer.
The error only occurs about once a week (SFTP down- and upload every two minutes around the clock), so I will send you the requested log when the error occurs the next time.

Greets, OmmyT

Reply with quote

utsav.manik
Joined:
Posts:
1
Location:
India

WinSCP error code3 issue

I am also facing same error:
I think change in Service architecture can solve.
We can create separate console application which gets inputs from Service and perform WinSCP task and then send control back to Service.

This is just an idea. Need to apply on my application. Need suggestion.
What you say guys? Will it work?

Reply with quote

martin
Site Admin
martin avatar

Re: WinSCP error code3 issue

@utsav.manik: Not sure it helps. Other users are getting the error even for short-lived application that executes regularly from Windows Scheduler.

I have sent you an email with dev version of the assembly and some more questions/information.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

@demax: Can you (and anyone else) describe in very details, how do you use WinSCP .NET assembly? What environment? How long does a single session last on average? How frequently do you open session and in what intervals? How many sessions does it take before the error start happening? Is the process using WinSCP .NET assembly running continuously or not?

I'm trying to find out how to reproduce the problem.

Reply with quote

Guest

We are getting this error in our system and using the .dll in a Windows Service that runs a few WinSCP commands every 2 minutes. It takes approximately 2-3 days in order for the error to happen. Currently, we just restart the machine in order to fix it.

Reply with quote

james99
Guest

We are currently using the 16/03/2013 dev build of WinSCP (assembly file version 1.1.0.3099).

We have two scheduled tasks set up, one that runs every 5 minutes, the other every 10 minutes. They both call a fairly straightforward console app that uses the WinSCP dll. Note they both connect to the same SFTP site, and will be running concurrently sometimes (not sure if this is related to the issue or not). The session remains open for some time (around 1m-1m30s), as we transfer all files from within around 20 folders to the SFTP site (and vice versa). Both processes ran completely fine for over a month before we received the following error (once the error occurred once, it continued occurring every time the processes ran until we restarted the machine to fix the issue):
[2013-06-09 15:10:26.972Z] [0001] Exception: WinSCP.SessionLocalException: WinSCP process terminated with exit code 3 and output "", without creating a log file.
[2013-06-09 15:10:26.972Z] [0001] Exception: WinSCP.SessionLocalException: WinSCP process terminated with exit code 3 and output "", without creating a log file.
at WinSCP.Session.Open(SessionOptions sessionOptions)
The next time the error occurs I'll try to fire up Process Monitor and send you a .pml file.

Reply with quote

Advertisement

iverchenko
Joined:
Posts:
3

I have same symptoms but another error message.
My error is "WinSCP.SessionRemoteException: Connection failed."
I ve posted about it on another thread (https://winscp.net/forum/viewtopic.php?t=12533)

And my app worked fine couple of months. And i think i saw this error only once, but i didn't recognize it that time. But last week i've updated my app so it runs two instances of winscp in different threads and connects to the same host in parallel. And the rate of error dramatically increased.
So may be it's the key?

Do any of you run parallel connections?

Reply with quote

Yasin
Guest

Same problem here

Same here. We are using WinSCP .NET Library with PowerShell. Powershell is being run automatically from a product called Microsoft System Center Orchestrator. you can think of it as an automation software. What we get is:
Exception calling "Open" with "1" argument(s): "WinSCP process terminated with exit code 3 and output "", without creating a log file."
This happens seldom but when it happens, it affects our production.

Script is:
[Reflection.Assembly]::LoadFrom("C:\OpalisOneSource\Logs\fldOptiCash\WinSCP-5.1.5\WinSCP.dll") | Out-Null
 
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "172.19.1.81"
$sessionOptions.UserName = "opalis"
$sessionOptions.Password = "PASSWORD CHANGED HERE"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 RSA-KEY-CHANGED-HERE"
 
$session = New-Object WinSCP.Session
$session.Open($sessionOptions)
 
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.FilePermissions = $null
$transferOptions.PreserveTimeStamp = $false
 
$localpath = "C:\OpalisOneSource\Logs\fldOptiCash\FOLDER HERE"
$remotepath = "/FOLDERA/FOLDERB/*.csv"
 
$transferResult = $session.GetFiles($remotepath, $localpath, $False, $transferOptions)
 
$arr = New-Object collections.arraylist
$transferResult.transfers | foreach{$arr.Add($_.FileName)}
 
$session.Dispose()
Please note that, this code is being run via Orchestrator's service. If it fails like above, i restart the service and problem is solved. But after 3-4 days, same thing happens.

I'm aware that a bug record is open for a long time. Please help solve this problem since we love and use WinSCP in a very important production environment.

Regards,

Yasin Uzman
yasinuzman |a t| gmail.com

Reply with quote

agriffin
Joined:
Posts:
7

Ongoing with this issue

  • Seeing this for a while now, apparently since Feb-Mar. Using Visual Cron to kick off the task, running ~ 20 times/ hour (20 separate jobs, each runs every hour, staggered)
  • Visual Cron runs a Perl script that kicks off a filemasked download(this was happening on another server with uploads as well but has been replaced with a different batch job).
  • Last reboot fixed the problem for ~ 2 weeks. This system is crucial to several environments, and can't be rebooted without announced downtime, so the problem is a bit exacerbated.
  • Short sessions, usually 4-8 files ranging from 1-4000 MB in size.
  • Once the bug hits, WinSCP will not run from *any* automated process until the system is rebooted. It will not run a simple command line connect from windows task scheduler, from the automation software we are using, or anywhere else automated, regardless of user account.
  • The process that launches it (Visual Cron)runs as a service, but restarting the service has no effect.
  • Userland command Windows continue to function normally.

Reply with quote

demax
Joined:
Posts:
4
Location:
Stockholm

We are using the .NET assembly and have created an .exe that's scheduled to fire off every 5 minutes. To answer your questions:

how do you use WinSCP .NET assembly?
Yes

What environment?
Server 2008R2

How long does a single session last on avarage?
~30-60 seconds

How frequently do you open session and in what intervals?
Every 5 minutes, 24/7

How many sessions does it take before the error start happening?
Unclear, It was running fine for about 3 months before this error appeared.

Is the process using WinSCP .NET assembly running continuously or not?
no, started and stopped every time the scheduled task is triggered and the job is finished

I'm starting to think that this has got something to do with the windows desktop heap size for non-interactive desktop sessions. Sometimes we receive error code "0xC0000142" from task scheduler. i'm aware of that the desktop heap is only for storing graphical/form objects but could it be the case that even tho winscp.exe is ran non-interactive there is something that has to do with the interface that's initialized?

Thanks in advance

Reply with quote

Advertisement

agriffin

Win 2K3 compatibility mode?

Can anyone here say they won't make it more than a week reliably? If so, can you set the WinSCP executables to run in Win 2003 compatibility mode for all users? We have made this change and haven't seen a problem since, but the intermittent nature of this error makes it difficult to say. Additionally, has anyone tried seeing if changing the desktop heap makes a difference?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: .NET library - error while running scheduled task

Thanks for all the reports. Sorry for late answer, I was away on vacation.

I read all the new and old reports over and over again. I seems the problem is occurring on Windows 2008 (R2 SP1) only (though for some reports where I know Windows version number 6.1.7601, it can also be Windows 7 SP1).

That may explain why I was not able to reproduce the problem on my Windows 8 test machine, where I have a task scheduled every minute for over 4 months without a single problem. I have tried now to intensify the test by running multiple sessions in parallel as @iverchenko suggested.

Can others test suggestion by @agriffin to set process to run in 2003 compatibility mode?

Reply with quote

mshah
Joined:
Posts:
1

same problem with multiple sessions

Hi Friends,
I have same problem with running multiple sessions on win server 2008 R2. I am badly stuck at this, kindly help if anybody has a solution.
thanks,

Reply with quote

martin
Site Admin
martin avatar

Re: .NET library - error while running scheduled task

I was able to reproduce the problem in the end. It took about 11 days and 100 000 sessions. Unfortunately, my machine crashed shortly afterwards, before I even noticed, so I was not able to debug the issue. I'm running second round now.
Anyway, inspecting the logs, I'm pretty sure now, the root cause in not in WinSCP, but rather in Windows OS (or .NET framework).

Reply with quote

Advertisement

jasongk
Joined:
Posts:
1

I too have this error. When do you think this error could be fixed?
(please don't take this as I'm pressuring you or anything to fix this, I'm just curious)

Some more info just in case:

OS: Windows 2008 R2 server
.NET version: 3.5

Application is using the dll from the download page (version 5.1.4).
I run the application every day at a set time (9am) once, I started to get these errors
Could not open session, WinSCP process terminated with exit code 3 and output "", without creating a log file.
I use this dll in my C# application. The application connects to an SFTP remote server and downloads a bunch of files (around 20).
Application is scheduled to run via the MSSQL Server agent and not via Windows Scheduler.

Reply with quote

MEMScadman
Guest

Not just a .NET assembly problem

This problem is not limited to .NET library use. I am having a similar issue executing a WinSCP.com 5.2.1 script from a batch script inside a service built on srvany. The OS is Windows Server 2008 R2 Standard SP1.

The WinSCP script contains commands to perform a directory listing using FTP over SSL.
It runs every 5 seconds and and two such services running simultaneously fail after about a day, generating:
error code 3. No log file is created.
There was nothing in the Windows log files relating to the failure.

The symptoms are the same as others have reported – interactive operation runs fine but any background WinSCP operation fails – even if the service is stopped/restarted. Apparently, there is a resource that has been exhausted as the machine must be rebooted to recover.

An attempt to run procmon, filtered for WinSCP, caused it to run out of memory after about an hour.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

jasongk wrote:

I too have this error. When do you think this error could be fixed?
(please don't take this as i'm pressuring you or anything to fix this, i'm just curious)
As I wrote above, I have no reason to believe this is bug of WinSCP and hence that there's anything to fix.
I believe it is bug in Windows. I'm trying to find out why it Windows entering this dead state and if there's any workaround to employ to prevent that. No luck so far. Still trying... I was able finally to reproduce the problem myself (after 100 000 runs), what makes it easier for me to debug this.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: not just a .net assembly problem

MEMScadman wrote:

This problem is not limited to .NET library use. I am having a similar issue executing a WinSCP.com 5.2.1 script from a batch script inside a service built on srvany. The OS is Windows Server 2008 R2 Standard SP1.
Thanks for your report. I suspected that this is the case. Knowing it for sure narrows the problem down to Windows OS (previously I also suspected .NET framework).

Reply with quote

Advertisement

bitterman1
Guest

Re: not just a .net assembly problem

It is well known that the exit code 3 is caused by abort() function
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/abort

It may be possible (although very improbable) that the C Runtime calls abort() on startup. Otherwise, it is the user program (or any of the dependent libraries) that calls abort() or otherwise causes SIGABRT. Although WinSCP source doesn't call this function as-is (as far as I could ascertain after a rather cursory look), OpenSSL library most certainly does.

I suggest a deeper look into it.

Reply with quote

martin
Site Admin
martin avatar

Re: not just a .net assembly problem

@bitterman1: I was able to reproduce this problem will very simple console application, with no code whatsoever and definitely no OpenSSL library. So it's somewhere within C++ Builder libraries. I'm still looking into this (trying to build debug version of the libraries).

Reply with quote

bitterman1
Guest

Re: not just a .net assembly problem

@martin: I was wondering if a simple executable compiled with another compiler (Visual C++, Intel, GNU++) also aborts on startup under the same conditions.

Reply with quote

Advertisement

joshillian
Guest

Re: not just a .net assembly problem

As other mentioned earlier in the thread, I too found that switching to Windows 2003 for the task type seemed to resolve my problem.

Appreciate those that contributed the suggestion. The problem had been a significant pain as of late.

Reply with quote

martin
Site Admin
martin avatar

Re: not just a .net assembly problem

@joshillian: Thanks for your report. What exactly did you do? Did you change a scheduler task settings or WinSCP process/executable settings?

Reply with quote

goetterfunke
Guest

same Error

I just want to say that we are also working on the exact same error message.
We use a C# service with the .NET assembly and after each loop we get the error 3 from WinSCP.

System is 2008 R2 x64

Reply with quote

Advertisement

Phuc Pham
Guest

Re: .NET library - error while running scheduled task

Hi @martin,
Any updates on this?
I'm facing the same issue and need your help.
My email: phuphucpham@gmail.com
Thanks,
Phuc

Reply with quote

JKL
Joined:
Posts:
6
Location:
Poland

I have the same problem.

The error is:
WinSCP.SessionLocalException: WinSCP process terminated with exit code 3 and output "", without responding (response log file was not created). This could indicate lack of write permissions to the log folder or problems starting WinSCP itself.
But it only occurs when I run it via Task Scheduler.

The funny thing is that it runs with no problem when I start it manually. Same user logged in that runs scheduled task. Same application. The only difference is that running through task scheduler gives me error.

Running on Windows Server 2008 R2 Standard.

I have already tried versions 5.1.7 and 5.2.6.

Compatibility mode makes no difference.

Can you help?

one more observation

If in task properties on General tab in Security options I set the radio to "Run only when user is logged in" – no error.
"Run whether user is logged on or not" – error.

Another one:
Friend told me that it happens because WinSCP requires User Environment. He suggested that to solve it I should use SSH Stack instead of sending parameters to application.

I don't really know what that means, but maybe it will help you out.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

JKL wrote:

I have already tried versions 5.1.7 and 5.2.6.

Compatibility mode makes no difference.

Can you help?
Did you restart your machine?

Quote from Bug 996:
While the fixed versions no longer gradually exhaust system resources, they cannot recover resources exhausted by previous buggy versions. So it's still necessary to restart affected machine to recover the system.
Let us know if it helped.

Reply with quote

JKL
Joined:
Posts:
6
Location:
Poland

martin wrote:

Did you restart your machine?
It's not that simple I'm affraid.
Can you tell me why restarting it might have meaning?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

@JKL: I've already quoted an explanation above, once again:
While the fixed versions no longer gradually exhaust system resources, they cannot recover resources exhausted by previous buggy versions. So it's still necessary to restart affected machine to recover the system.
So please, give it a try.

Reply with quote

Advertisement

Army
Guest

Windows Server 2008 R2 error

Hi Everyone,

Although this post is a couple months old now, I came across it only by fluke, but thought I would share my findings on this, just to see if it helps anyone.
We're running multiple scheduled tasks on a Windows Server 2008 R2 SP1, .NET Framework version 4.5.
Every months / 3 weeks we get a similar and annoying 0xc0000142 result code for all of our scheduled tasks. It seemed to have sorted by forcing the task to restart on error inside Task Scheduler, however this issue reappeared a couple of weeks ago.

A restart is definitely the only solution, while the cause in our case seems to be pending Windows updates.

Basically, every time the error code appears in the Task Scheduler it's for sure that there's an update requiring restart in the background.
I'm not entirely sure if it's connected to the atoms mentioned in the StackOverflow thread, but it's very annoying and would appreciate any solutions you might have.

Cheers!

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: Windows Server 2008 R2 error

Army wrote:

Basically, every time the error code appears in the Task Scheduler it's for sure that there's an update requiring restart in the background.
I'm not entirely sure if it's connected to the atoms mentioned in the StackOverflow thread, but it's very annoying and would appreciate any solutions you might have.
Is the 0xc0000142 an actual exit code of WinSCP? Can you give us more details on the task? (how does it interact with WinSCP)

Reply with quote

Army
Joined:
Posts:
2
Location:
UK

Re: Windows Server 2008 R2 error

Hey Martin,

Thanks for getting back.

martin wrote:

Is the 0xc0000142 an actual exit code of WinSCP? Can you give us more details on the task? (how does it interact with WinSCP)
No, that's what I was trying to reflect on that it doesn't seem to be a WinSCP issue, but more like a Windows Server 2008 R2 issue whereby if there's a Windows update pending the task throws this error code in Task Scheduler. So it's definitely an internal (probably Windows?) error code, and I'm receiving it just like people up the thread even though my scheduled task has nothing to do with WinSCP..
I was just wondering if anyone found anything useful regarding this issue as I couldn't find anything on official forums.. :?

Reply with quote

roby1121
Guest

Re: Windows Server 2008 R2 WINSCP error

The same for me.
On my server Windows 2008 R2 an update for Java was waiting for running. In this situation WinSCP returns the following error message:
winscp process terminated with exit code 3 and output....
I made the Java update and next WinSCP works fine.
Thanks for your suggestion.

Roberto

Reply with quote

Advertisement

oviganesh
Joined:
Posts:
7
Location:
USA

@martin: Do we have any solution for this issue? i am having same issue in "Windows Server 2012 R2 Standard"
WinSCP process terminated with exit code 3.
There was no output. Response log file C:\Windows\TEMP\wscp4310.03C09FDF.tmp was not created.
This could indicate lack of write permissions to the log folder or problems starting WinSCP itself.
It is getting resolved after I reboot the server, but after three days getting the same issue. I am running .NET Core service as Windows Service which is using WinSCP 5.19.5.0 to download the files from FTP location.

Please let me know if you have any solution for this issue.
Last edited by oviganesh on 2022-02-02 16:37; edited 1 time in total

Reply with quote

oviganesh

@martin: Thanks for your reply. I did check the system resources. It looks good to me. After I restart the server, it was running successfully for 5 days, again today it is failed with same exception. Please let me know anything else can be done to resolve this issue.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum