Resume File Transfer After Disconnect - WeOnlyDo Discussion board

Resume File Transfer After Disconnect (wodSFTP / wodSFTP.NET / wodSFTPdll)

by Christian, Monday, August 17, 2009, 23:31 (5360 days ago)

We are trying to send a file to an external client, but they appear to have an auto-disconnect after 15 minutes.

I was hoping to resolve the issue by setting the Resume property to TRUE, but it seems that the Resume property doesn't reconnect after a disconnection. So, I tried the following code:

[code]
while (retryCount < 3)
{
try
{
if (!ftp.State.Equals( Connected ))
{
ftp.Connect();
}
ftp.PutFile(SourceFilePath, DestinationFilePath);
}
catch (Exception ex)
{
retryCount++;
if (retryCount > 2)
{
return Error: + ex.Message + + ftp.State;
}
}
}[/code]

The process runs longer than the original 15 minutes, but then I receive the following error message:

Error: Please disconnect first. Connected

So, the error is telling me to disconnect first, but the FTP State says that it's still connected. What am I missing? Am I using the Resume property correctly? Is there a better way to reconnect to a server and resume file transfer?

Thanks

Re: Resume File Transfer After Disconnect

by wodDamir, Monday, August 17, 2009, 23:52 (5360 days ago) @ Christian

Hi Christian,

The error you receive is most probably because Connect got called for some reason.

However, why don't you try using Disconnected Event to reconnect to server?

Regards,
Damba

Re: Resume File Transfer After Disconnect

by Christian, Tuesday, August 18, 2009, 05:12 (5359 days ago) @ wodDamir

Ah, makes sense. I'll try that.

Just to clarify, though, will the resume functionality work after a server disconnect? If I re-connect and call the PutFile command again, will it resume where it left off or will the file transfer start all over again?

Re: Resume File Transfer After Disconnect

by wodDamir, Tuesday, August 18, 2009, 10:31 (5359 days ago) @ Christian

Christian,

If you call putfile with the same remote name, resume set to true, and if server supports resuming file transfers, then yes. The component will automatically continue uploading file.

Regards,
Damba