Connection Timed Out after several transfers
Good afternoon and thank you for a great program! I have successfully integrated version 5.07 into a vb.Net application that I am using. I am running this on my pc with the webpage on a local server to me and transferring to a remote SFTP server. I normally have no problems whatsoever but recently had to upload about thirty files in succession. My app is programmed to take one file at a time and upload it. I found that after sending 5 files in quick succession, the next send fails with the error:
Error: WinSCP.SessionRemoteException: Network error: Connection timed out. at WinSCP.SessionLogReader.Read(LogReadFlags flags) 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.WaitForNonEmptyElementAndCreateLogReader(String localName, LogReadFlags flags) at WinSCP.CustomLogReader.WaitForGroupAndCreateLogReader() at WinSCP.Session.Open(SessionOptions sessionOptions) at FTNOrders.UploadFileUsingFTP(String FTPFileName, Int32 batch) in Q:\IT\WebSite\MyWeb\Orders.aspx.vb:line 220
I recently added the sftpsession.Dispose() to see if that would correct it but to no avail. I do not see a connection close option but thought that something is not being properly recycled.
This is my code:
Try
' Setup session options
Dim sftpsessionOptions As New SessionOptions
With sftpsessionOptions
.Protocol = Protocol.Sftp
.HostName = "ftpserver.xxxxxxx.com"
.UserName = "MyUserName"
.Password = "MyPassword"
.SshHostKey = "Key here....."
End With
Dim sftpsession As Session = New Session
Using sftpsession
' Connect
sftpsession.Open(sftpsessionOptions)
' Upload files
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
Dim transferResult As TransferOperationResult
transferResult = sftpsession.PutFiles("\\localserver\share\" + Trim(FTPFileName), "/remotedir/", False, transferOptions)
' Throw on any error
transferResult.Check()
' Print results
Dim transfer As TransferEventArgs
For Each transfer In transferResult.Transfers
tbxxx.Text = ("Upload of " + Trim(transfer.FileName) + " succeeded.")
Next
End Using
sftpsession.Dispose()
Catch e As Exception
tbxxx.Text = "Error: " + e.ToString
'Return 1
End Try
Any help with this would be GREATLY appreciated!
Scot Sunnergren
Error: WinSCP.SessionRemoteException: Network error: Connection timed out. at WinSCP.SessionLogReader.Read(LogReadFlags flags) 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.WaitForNonEmptyElementAndCreateLogReader(String localName, LogReadFlags flags) at WinSCP.CustomLogReader.WaitForGroupAndCreateLogReader() at WinSCP.Session.Open(SessionOptions sessionOptions) at FTNOrders.UploadFileUsingFTP(String FTPFileName, Int32 batch) in Q:\IT\WebSite\MyWeb\Orders.aspx.vb:line 220
I recently added the sftpsession.Dispose() to see if that would correct it but to no avail. I do not see a connection close option but thought that something is not being properly recycled.
This is my code:
Try
' Setup session options
Dim sftpsessionOptions As New SessionOptions
With sftpsessionOptions
.Protocol = Protocol.Sftp
.HostName = "ftpserver.xxxxxxx.com"
.UserName = "MyUserName"
.Password = "MyPassword"
.SshHostKey = "Key here....."
End With
Dim sftpsession As Session = New Session
Using sftpsession
' Connect
sftpsession.Open(sftpsessionOptions)
' Upload files
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
Dim transferResult As TransferOperationResult
transferResult = sftpsession.PutFiles("\\localserver\share\" + Trim(FTPFileName), "/remotedir/", False, transferOptions)
' Throw on any error
transferResult.Check()
' Print results
Dim transfer As TransferEventArgs
For Each transfer In transferResult.Transfers
tbxxx.Text = ("Upload of " + Trim(transfer.FileName) + " succeeded.")
Next
End Using
sftpsession.Dispose()
Catch e As Exception
tbxxx.Text = "Error: " + e.ToString
'Return 1
End Try
Any help with this would be GREATLY appreciated!
Scot Sunnergren