Location: United States
Posted: 2012-08-28 19:11
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:
' Setup session options
Dim sftpsessionOptions As New SessionOptions
.Protocol = Protocol.Sftp
.HostName = "ftpserver.xxxxxxx.com"
.UserName = "MyUserName"
.Password = "MyPassword"
.SshHostKey = "Key here....."
Dim sftpsession As Session = New Session
' 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
' Print results
Dim transfer As TransferEventArgs
For Each transfer In transferResult.Transfers
tbxxx.Text = ("Upload of " + Trim(transfer.FileName) + " succeeded.")
Catch e As Exception
tbxxx.Text = "Error: " + e.ToString
Any help with this would be GREATLY appreciated!
Location: Prague, Czechia
It looks like you are creating new connection for every single file. Your FTP server may prevent too many consecutive connections.
Ty to reuse the connection.
Location: United States
Posted: 2012-08-30 14:05
Thank you. My problem is that this is subroutine of a web page and not of a console app. It gets called when a button is clicked on the web page to send a file. The session options are created in the sub and the session is opened in the sub. I would have thought that those would then be destroyed when the sub exits normally.
I apologize if this is a stupid question but if I create the session and open the connection when the user first initiates a send, will that session stay open? How do I reconnect to it? On subsequent calls,the session objects will no longer exist. I could store the object in a session variable if that is what it takes... and remove the .Dispose method from the subroutine...
Posted: 2015-09-29 13:30
How to fix this problem..what is the reason for this problem?...Someone please help me...
You can post new topics in this forum
And it's free!