Topic "Connection Timed Out after several transfers"

Author Message
[View user's profile]

Joined: 2012-07-12
Posts: 2
Location: United States
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
With sftpsessionOptions
.Protocol = Protocol.Sftp
.HostName = ""
.UserName = "MyUserName"
.Password = "MyPassword"
.SshHostKey = "Key here....."
End With

Dim sftpsession As Session = New Session

Using sftpsession
' Connect

' 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.")
End Using

Catch e As Exception
tbxxx.Text = "Error: " + e.ToString
'Return 1
End Try

Any help with this would be GREATLY appreciated!

Scot Sunnergren
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24755
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.
Martin Prikryl
[View user's profile]

Joined: 2012-07-12
Posts: 2
Location: United States
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...

Thank you
elangovan M


How to fix this problem..what is the reason for this problem?...Someone please help me...

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License