Recurring task to upload a file using SFTP

Hi

I wonder if someone can offer some advice.
I have a recurring job that uploads a file via SFTP.

This code works perfectly when run locally, but once it is invoked via Hangfire the job completes but the file content is not uploaded - a zero byte file is created on the remote host.

I’m thinking it might be a threading issue but the logging I have added to the job doesnt give me any insight, there is no exception being raised and the synchronous file upload (the library is the latest version of SSH.Net via nuget but I can recreate the issue using Tamir SSH also) is executed without actually transferring the data.

I’d really appreciate any pointers.

I’m afraid that you would need to show us parts of your code that reads your local file and uploads it via ftp for us to be able to help.

Ftp uses two sockets. One for the commands, and one for the data. Your program is not waiting for the command socket to receive notification that the file is finished transmitting on the data socket. You need something like a thread-wait in your code. Consult the documentation for the library you’ve using, because it sounds like it’s running asynchronously.

Moderators - please close, the issue was with the input stream, Hangfire was irrelevant.