Cannot initialize external console

Advertisement

ssch
Joined:
Posts:
4

Cannot initialize external console

Issue: When a web application hosted on W2K8 server environment, it is not uploading file to the linux server.

SNIPPET of the web page calling a webservice.

string host = ConfigurationManager.AppSettings["HOST"].ToString();
string user = ConfigurationManager.AppSettings["USER"].ToString();
string password = ConfigurationManager.AppSettings["PW"].ToString();
string hostkey = ConfigurationManager.AppSettings["KEY"].ToString();
string tempFilePath = ConfigurationManager.AppSettings["INFILE"].ToString();
string outFilePath = ConfigurationManager.AppSettings["OUTFILE"].ToString();

KillWinSCPProcesses("WinSCP");
//// create temporary input file out of input stream
File.WriteAllBytes(tempFilePath+fileName, inputStream);
FileInfo fi = new FileInfo(tempFilePath+fileName);
if (!fi.Exists)
throw new Exception("Failed to create input file.");
string fileFull = fi.FullName;
string fileNameWExt = fi.Name;
string fileExt = fi.Extension;
// open file upload session
Session session = openFileUploadSession(host, user, password, hostkey);

// upload the file
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult = session.PutFiles(tempFilePath+fileName, outFilePath+fileName, false, transferOptions);

// check upload status
transferResult.Check();



///// Snippet for OpenFileUploadsession

SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "xxx",
UserName = "xxx",
Password = "xxx",
SshHostKeyFingerprint = "ssh-rsa 2048 xx:4c:xx:ef:2f:29:c0:62:b7:37:5c:xx:73:0a:xx:7b"
};
Session session = new Session()
session.DisableVersioncheck = true;
session.Open(sessionOptions);



I have capture all the Exeception in C# and it fails at session.OPEN(). It says "cannot initialize external console".
at WinSCP.ElementLogReader.Read(LogReadFlags flags)
at WinSCP.CustomLogReader.TryWaitForNonEmptyElement(string localName, LogReadFlags flags)
at WinSCP.CustomLogReader.WaitForNonEmptyElement(string localName, LogReadFlags flags)
at winSCP.CustomLogReader.WaitForGroupAndCreateLogReader()
at WinSCP.Session.Open(SessionOtpions sessionOptions)


NOTE: Same code it works on my local machine with a VS2010...
I have build a simple Console app when i run on the hosted server it works fine as well.

Reply with quote

Advertisement

Guest

Re: Cannot initialize external console

martin wrote:

This is probably this know issue that we unfortunately do not have a solution for:
https://winscp.net/tracker/1317


By using LocalSystem as the Identity of the web site's Application Pool, I made it work on my desktop (Windows 7 Pro 64bit). However,the same setting could not make the same code work on Windows Server 2008 R2 and Windows Server 2012 R2.

The Windows Task Manager shows WinSCP.exe is actually started on the server by the System account when the code is executed in the web application, but it won't create the session to the FTP server. The exception message is

"Timeout waiting for WinSCP to respond - WinSCP has not responded in time (response log file C:\TEMP was not created). This could indicate lack of write permissions to the log folder or problems starting WinSCP itself."

I already double check the C:\temp folder existed on the server and user has write permission on the C:\Temp folder.

Any update on this bug?

Reply with quote

Advertisement

You can post new topics in this forum