sshnet / sshnet/SSH.NET

Can't upload large file over SFTP (SshOperationTimeoutException)

Abierto
#103 7 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
C#
Estrellas
4.4k
Forks
993
Merge medio
9 d 21 h
PR fusionados (30 d)
1

Descripción

For uploading .csv file over SFTP I use SSH.NET (version 2016.0.0).

The file which needs to be send is rather large (~7GB), and in about an hour after the uploading started it throws the exception Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out.

Here is my actual uploading code.

using (SftpClient client = new SftpClient(command.FtpHost, command.UserName, command.Password))
{
    client.Connect();
    client.ChangeDirectory(command.FtpTargetFolder);

    // played a lot with BufferSize property
    // tried to use the default value, tried 4*1024 and 8*1024
    client.BufferSize = 2 * 1024; 

    using (FileStream fileStream = new FileStream(command.LocalFilePath, FileMode.Open))
    {
        client.UploadFile(fileStream, PrepareFileName(command.LocalFilePath));
    }
    client.Disconnect();
}

But this code works fine with smaller (tried with 1-4GB files) files than my desirable one (~7GB). I thought that it could depends on BufferSize, but playing with this property didn't fix the problem.

Here is the issue's stack trace.

Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
at Renci.SshNet.Channels.Channel.GetDataLengthThatCanBeSentInMessage(Int32 messageLength)
at Renci.SshNet.Channels.Channel.SendData(Byte[] data, Int32 offset, Int32 size)
at Renci.SshNet.Sftp.SftpSession.SendRequest(SftpRequest request)
at Renci.SshNet.Sftp.SftpSession.RequestWrite(Byte[] handle, UInt64 offset, Byte[] data, Int32 length, AutoResetEvent wait, Action'1 writeCompleted)
at Renci.SshNet.SftpClient.InternalUploadFile(Stream input, String path, Flags flags, SftpUploadAsyncResult asyncResult, Action'1 uploadCallback)

Also I've noticed that usually uploading throws the error in 1 hour after start and by that time it's uploaded ~80-90% of entire file (because I see not fully uploaded files in my destination SFTP folder).

Does someone has an idea why it's happening?
Btw I've asked StackOverflow question regarding that: http://stackoverflow.com/questions/40158501/cant-upload-large-file-over-sftp
Thanks in advance.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza siguiendo la ruta del stack trace a través de SftpClient.InternalUploadFile, SftpSession.RequestWrite, Channel.SendData y Session.WaitOnHandle. Reproduce una carga SFTP grande con una duración cercana a la reportada y determina por qué se produce el tiempo de espera de la sesión; se considera terminado cuando la transferencia se completa sin que se produzca un tiempo de espera y el comportamiento queda cubierto por una prueba de regresión adecuada.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp
Área
networking
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.