Why am I getting an End of File exception when using PutFileAsync?

0 votes
asked Nov 28, 2018 by kenswift (140 points)

I have a program that is uploading a number of large files and I would like to send these asynchronously, but I am receiving an End of File exception.

The async call is pretty straightforward:

Task task = _sftp.PutFileAsync(localPath, remotePath, null);

This method is called from within a foreach loop and after the loop there is a blocking call to wait for the files to complete processing

Task.WaitAll(taskList.ToArray());

When I look at the status message of the taskList, I see the EOF exceptions. Below are a couple of the error messages from the logger:

2018-11-27 18:05:20.126 INFO Sftp(1)[13] Response: SSHFXPSTATUS (90, 1, 'End of file')

2018-11-27 18:05:20.133 ERROR Sftp(1)[13] Info: Rebex.Net.SftpException: End of file; End of file.
at Rebex.Net.GRU.NR(DIU I, Type R)
at Rebex.Net.Sftp.IKI(TOU I, YIU R, String O, Stream U, Int64 N, Int64 D, TEU V)

Thanks in advance for any help and guidance you can provide! I have been beating my head against my desk for days on this one.

Ken

Applies to: Rebex SFTP
commented Mar 29 by Lukas Matyska (59,450 points)
We have an update for this question.
Please, see my updated answer: https://forum.rebex.net/9415/why-am-getting-an-end-file-exception-when-using-putfileasync?show=9417#a9417

1 Answer

0 votes
answered Nov 28, 2018 by Lukas Matyska (59,450 points)
edited Mar 29 by Lukas Matyska

Can you please send us complete log file to support@rebex.net for analysis?
Please, create it with LogLevel.Debug.

We need to see all actions the client requested.


UPDATE:

We have received a log file from one of your colleagues with the exact same issue recently. The log revealed serious bug at the server.

What was happening:

  1. The client started a file upload.
  2. The client executed another commands simultaneously while uploading the file from step 1.
  3. The server identified one of those commands with the exact same file handle used to identify current file upload.
  4. When the client closed the handle to finish the other command, it broke the unfinished file upload.
  5. Server then reported the 'End of file' error for the unfinished file upload.

Possible solutions:

  1. Report this bug to your server vendor and use the fixed server.
  2. Do not execute multiple commands simultaneously when working with this server.
    Instead, use multiple Sftp clients to execute commands in parallel.
...