Timeout waiting for WinSCP to respond

Advertisement

vvreddy143
Joined:
Posts:
1
Location:
Hyderabad

Timeout waiting for WinSCP to respond

Hi,

When I am trying to upload file with size "500KB" using .NET class library or script, I am getting error as "Timeout waiting for WinSCP to respond" and file ending up with 0KB with file extension ".filepart".

When I am trying to upload "1KB" file, it was successful.

I have attached sessionlog, debuglog and .NET exception log here. Please assist me.

Reply with quote

Advertisement

marnold316
Joined:
Posts:
4

I have the same problem as well.

I have the same problem with larger files but on just one client. I tested with 300KB files and I got the 0KB filepart, I did a test with a 67KB file and got the 0KB filepart, when I did a test with a 2KB file it uploaded just fine. I am using the latest NuGet package, the version is 5.21.2.0. I had the same problem in an older version of WinSCP as well. I am using SFTP as a server, the server has plenty of drivespace, the server is running FreeFTPD and is working well with other clients uploading using the .NET WinSCP.

The SFTP server shows a disconnect right after the filepart upload which does not show as a failure.
08-24-2022 15:20:59 HOST 173-13-11-33-Michigan.hfc.comcastbusiness.net SFTP 143 is changing dir to / (C:\inetpub\wwwroot\GCRemoteTools_WaltersDimmick\AuditMedia\143\)
08-24-2022 15:20:59 HOST 173-13-11-33-Michigan.hfc.comcastbusiness.net SFTP 143 is listing /In (C:\inetpub\wwwroot\GCRemoteTools_WaltersDimmick\AuditMedia\143\In\1614_c4_0_1661262050.jpg)
08-24-2022 15:20:59 HOST 173-13-11-33-Michigan.hfc.comcastbusiness.net SFTP 143 is listing /In (C:\inetpub\wwwroot\GCRemoteTools_WaltersDimmick\AuditMedia\143\In\1614_c4_0_1661262050.jpg.filepart)
08-24-2022 15:20:59 HOST 173-13-11-33-Michigan.hfc.comcastbusiness.net SFTP 143 is uploading /In/1614_c4_0_1661262050.jpg.filepart (C:\inetpub\wwwroot\GCRemoteTools_WaltersDimmick\AuditMedia\143\In\1614_c4_0_1661262050.jpg.filepart)
08-24-2022 15:21:00 HOST 173-13-11-33-Michigan.hfc.comcastbusiness.net SFTP 143 disconnected
Let me know if you need anything else, thank you for looking into this matter, it is greatly appreciated.
Description: Logs from failed 300KB upload. There were 288 files in the folder that were about this size.
Description: Logs from failed 67KB upload.
Description: Logs from 2KB successful upload.

Reply with quote

marnold316
Joined:
Posts:
4

I tried the settings change recommended in the article and I still got filepart of 0 bytes on server

Martin, thank you for the quick response.

I added the AddRaw SendBuf 0 and it didn't change the result. Filepart is still 0 bytes on the server. I have attached the log files. I have about four other clients uploading to the same server without issue. I have other SFTP servers where your component works perfect with multiple clients connecting.

Here is the code I am using:
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = ftpType.Equals("sftp", StringComparison.OrdinalIgnoreCase) ? Protocol.Sftp : Protocol.Ftp,
    HostName = ftpHost,
    UserName = ftpUsername,
    Password = ftpPassword,
    Timeout = new TimeSpan(0, 0, 120)
};
 
if(ftpType == "ftp")
{
    sessionOptions.FtpSecure = FtpSecure.Implicit;
}
 
if(port != 0)
{
    sessionOptions.PortNumber = port;
}
sessionOptions.AddRawSettings("SendBuf","0");
 
if(ftpType.Equals("sftp", StringComparison.OrdinalIgnoreCase))
{
    sessionOptions.SshHostKeyFingerprint = sshKey;
}
 
TransferOperationResult transferResult;
 
using (Session session = new Session())
{
    if(FileTransferredEventHandler != null)
    {
        session.FileTransferred += FileTransferredEventHandler;
    }
    session.XmlLogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WINSCP_XMLLog.xml");
    log.InfoFormat("WINSCP XML Log Path= " + session.XmlLogPath);
    session.Timeout = new TimeSpan(0, 0, 130);
    // session.ReconnectTime = new TimeSpan(0, 0, 140);
    // Connect
    session.SessionLogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WINSCP_SessionLog.log");
    log.InfoFormat("WINSCP Session Log Path= " + session.SessionLogPath);
    session.DebugLogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WINSCP_DebugLog.log");
    log.InfoFormat("WINSCP Debug Log Path= " + session.DebugLogPath);
    session.DebugLogLevel = 2;
    // Connect
    session.Open(sessionOptions);
 
    // Upload files
    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = WinSCP.TransferMode.Binary;
    transferOptions.OverwriteMode = OverwriteMode.Overwrite;
    
    transferResult = session.PutFiles(string.Format("{0}\\*", dir), string.Format("{0}/", (String.IsNullOrWhiteSpace(remoteDirectory) ? "" : "/" + remoteDirectory)), true, transferOptions);
}
 
return transferResult.Transfers.Count;
Description: File logs for test with new AddRaw SendBuf 0 option.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
38,408
Location:
Prague, Czechia

Re: I tried the settings change recommended in the article and I still got filepart of 0 bytes on server

Try:
sessionOptions.AddRawSettings("SFTPMaxPacketSize","32768");

Reply with quote

Advertisement

marnold316
Joined:
Posts:
4

Still 0 byte filesize on filepart

I made the code change as requested and I am still getting a 0 byte filesize on filepart and the transfer never completes. As an FYI, I can transfer files just fine using the GUI app, just not thru the .NET library.

I left the previous settings change recommendation in the code:
sessionOptions.AddRawSettings("SendBuf","0");
sessionOptions.AddRawSettings("SFTPMaxPacketSize", "32768");
Thanks for your help Martin!
Description: Log files after adding SFTPMaxPacketSize

Reply with quote

marnold316

Strangely its working now

Martin,

I went back to do the test you requested and strangely everything is uploading now. I will monitor over the next week and let you know if I run into any issues. Thanks!

Reply with quote

Advertisement

You can post new topics in this forum