Program freezes after a timeout

Advertisement

jart07
Joined:
Posts:
4
Location:
US

Program freezes after a timeout

Greetings,

I'm developing a SFTP client, I'm connecting and downloading and everything. the problem comes with I'm downloading a big file >10Gb. I get a "A first chance exception of type 'System.TimeoutException' occurred in WinSCPnet.dll" the program keeps downloading with the filepart files. it downloads the complete folder from the server, the problem is that I have some other method or functions after the download and it's not getting there.

So, I don't Understand why after a time out it resumes but it doesn't run all the code.

can somebody explain me what is happening here?

Part of my code
Try
' Set up session options
Select Case opt

Case 1 ' Connect
AddHandler session.FileTransferProgress, AddressOf SessionFileTransferProgress

Dim sessionOptions As New SessionOptions
With sessionOptions
.Protocol = Protocol.Sftp
.HostName = "xxx"
.PortNumber = xxx
.UserName = "xxx"
.SshHostKeyFingerprint = "xxx"
.SshPrivateKeyPath = "xxxx"
.Timeout = New TimeSpan(26000)
.AddRawSettings("FSProtocol", "x")
.AddRawSettings("ProxyMethod", "x")
.AddRawSettings("ProxyHost", "xxxx")
.AddRawSettings("ProxyPort", "x")
End With


session.Open(sessionOptions)
MsgBox("Connection succesful", MsgBoxStyle.OkOnly)
flag = True
Case 6 ' download
Form1.ProgressBar1.Visible = True
Form1.lbldown.Visible = True
Form1.Label4.Visible = True

' Download files
'
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
transferOptions.ResumeSupport.State = TransferResumeSupportState.On
transferOptions.OverwriteMode = OverwriteMode.Resume

Path = Form1.txtfolder.Text.ToString
If Path = "" Then
MsgBox("Please select a valid path", MsgBoxStyle.Critical)
Else

Dim transferResult As TransferOperationResult
namefile = downloadpath.Remove(0, 1)
Path += "\" & namefile

Form1.ProgressBar1.Visible = True
transferResult= session.GetFiles(downloadpath, Path, False, transferOptions)
GoTo check
' Throw on any error
transferResult.Check()

If transferResult.IsSuccess = True Then
Goto check
Else
MsgBox("Download incompleted", MsgBoxStyle.Exclamation)
End If
End If

Private Shared Sub SessionFileTransferProgress(
sender As Object, e As FileTransferProgressEventArgs)
' New line for every new file

If (_lastFileName IsNot Nothing) AndAlso (_lastFileName <> e.FileName) Then
Form1.Label4.Visible = True
Form1.ProgressBar1.Invoke(New Action(Of Double)(AddressOf UpdateProgress), e.OverallProgress)
Form1.ProgressBar1.Visible = True
' Form1.lbldown.Text = e.FileName
Dim a = e.FileName.Substring(e.FileName.LastIndexOf("/"))
Form1.lbldown.Text = a

End If
'Remember a name of the last file reported
_lastFileName = e.FileName
local = e.Directory
End Sub

Private Shared _lastFileName As String

Private Shared Sub UpdateProgress(progress As Double)
Form1.ProgressBar1.Value = progress * 100
End Sub

Reply with quote

Advertisement

jart07
Joined:
Posts:
4
Location:
US

Re: Program freezes after a timeout

[quote="martin"]Did you try to step through your code? Sorry, but we cannot debug your code for you.[/quote]

Yeah I tried to debug it. I know you cannot debug it. I just want to know if you have any ideas what it can be. I tried to research my problem I haven't found my problem listed.

I tried to add some break point in visual studio and when it times out is like it wasn't running the code anymore. it doesn't take any of my break point listed.

for this reason, It's impossible for me to find what it's causing the problem.

when I work with small files(doesn't matter the size, it just matter of time) it works perfectly. The problem is when the tool is working for x amount of time and it times out. So, when that happens it just skips any process that comes after downloading the file. Also, the progress bar doesn't work anymore when it times out.

Reply with quote

martin
Site Admin
martin avatar

Re: Program freezes after a timeout

Sorry, I do not have any explanation for that. And it sounds quite unlikely to me in general.

Try setting Session.SessionLogFile and Session.DebugLogFile and attach the logs.

Reply with quote

jart07
Joined:
Posts:
4
Location:
US

Re: Program freezes after a timeout

[quote="martin"]Sorry, I do not have any explanation for that. And it sounds quite unlikely to me in general.

Try setting [m]Session.SessionLogFile[/m] and [m]Session.DebugLogFile[/m] and attach the logs.[/quote]

Thank you
I'll try that and I will post the results

Reply with quote

Advertisement

jart07
Joined:
Posts:
4
Location:
US

Re: Program freezes after a timeout

martin wrote:

Sorry, I do not have any explanation for that. And it sounds quite unlikely to me in general.

Try setting Session.SessionLogFile and Session.DebugLogFile and attach the logs.

Martin, I got the output from the log files and the problem seems to be the time out variable that is set to 0 -timeout=0 even though I set it up as .Timeout = New TimeSpan(26000) Do you have any ideas how I can change this ?

Thanks

ExeSessionProcess.ProcessEvent entering
[2018-02-26 14:07:41.635Z] [0006] Scheduling output: [Connecting to host...]
[2018-02-26 14:07:41.635Z] [0006] ExeSessionProcess.ProcessEvent leaving
[2018-02-26 14:07:41.635Z] [0006] ExeSessionProcess.ProcessEvent entering
[2018-02-26 14:07:41.635Z] [0008] Skipping 0 nodes
[2018-02-26 14:07:41.635Z] [0006] Scheduling output: [Host is not communicating for more than 0 seconds.]
[2018-02-26 14:07:41.635Z] [0006] Scheduling output: [Still waiting...]
[2018-02-26 14:07:41.635Z] [0006] Scheduling output: [Note: If the problem repeats, try turning off 'Optimize connection buffer size'.]
[2018-02-26 14:07:41.635Z] [0006] Scheduling output: [Warning: Aborting this operation will close connection!]

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,504
Location:
Prague, Czechia

Re: Program freezes after a timeout

jart07 wrote:

Martin, I got the output from the log files and the problem seems to be the time out variable that is set to 0 -timeout=0 even though I set it up as .Timeout = New TimeSpan(26000) Do you have any ideas how I can change this ?
Set the .Timeout to a reasonable number. TimeSpan(26000) is indeed 0, when rounded to whole seconds.

Reply with quote

Advertisement

You can post new topics in this forum