Login  
Search All Forums
Dart Home | PowerTCP SFTP & SSH for .NET | Custom Development Reply | PowerTCP SFTP & SSH for .NET Topics | Forums   
AuthorForum: PowerTCP SFTP & SSH for .NET
Topic: Possible hang with "Unexpected end of sftp stream" during file transfer
agladshtein

From: USA
Posts: 1
Member Since: 03/12/15
posted March 12, 2015 11:39 AM

We believe that the hang occurred while the sftp component was transferring a file.

In at least some cases, we believe that there may have been concurrent access to the source file. The file may have been written to, or renamed, while the transfer was in process. 

We would expect concurrent tampering with the source file to cause an exception during the download. However, we only saw hangs. We stream the sftp transfer into a file on the destination system, and we could see that it was created and usually remained at zero bytes and locked. We had to kill the service process that transfers the file in order to recover.

However, we do see, from our own logs, that an exception is occurring during a Dispose() of either the stream that is reading from the ftpclient, or the ftpclient itself. We don’t have line numbers from the stack trace, so we can’t be certain which of these threw an exception. It seems to us that a Dispose should not be throwing an exception like this. 
Here’s the diagnostic info we captured:

<exceptionSet Type="Error">
               <exception>
                       <time>2014-12-15T11:05:02.3756274-06:00</time>
                       <process>Dart.Ssh</process>
                       <exceptionclass>System.IO.IOException</exceptionclass>
                       <message>Unexpected end of sftp stream.</message>
                       <context>Ftp.ProcessIncoming: Communication error on channel Catalogs and Order Guides</context>
                       <userId>NOLOGIN</userId>
                       <loginUnitName>US Foods</loginUnitName>
                       <other>Void 2M(Byte[], Int32, Int32)</other>
                       <stackTrace>  at 2.6.2M(Byte[] , Int32 , Int32 )
                              at 2.6.2u(Int32 )
                              at 2.6.32()
                              at 1.3.Dispose(Boolean disposing)
                       at CBORD.NetMenu.Framework.UIBL.FtpChannel.ProcessIncomingData(IInterfaceEngine engine, Object arg, Nullable`1 transmissionId)</stackTrace>
               </exception>
</exceptionSet>



Here's our basic transfer logic, with some parts omitted for brevity.

try
{
        using (var conn = Connect(engine, ctx))
        {
                       ...
                       using (var outFileStream = File.Create(workFilePath))
                       {
                              using (var reader = conn.OpenRead(fileToProcess.FullPath))
                              {
                                      try
                                      {
                                             reader.CopyTo(outFileStream);
       
                                      }
                                      catch (Exception)
                                      {
                                             filePartiallyCopied = true;
                                             throw;
                                      }
                              }
                       }
        }              
}       
catch (Exception e)
{
        // try to delete partially copied file.
        if (filePartiallyCopied && workFilePath != null && File.Exists(workFilePath))
        {
               try
               {
                       File.Delete(workFilePath);
               }
               catch (Exception)
               {
               }
        }
        ...
        return;
        }
}       
Jamie Powell (Admin)

From: Rome, NY USA
Posts: 448
Member Since: 03/13/07

Extra Support Options
Custom Application Development

posted March 19, 2015 5:11 PM

Thank you for your post. An email has been sent to you requesting additional information. Please let me know if you have not received this email and I will be happy to resend.

All the best,
Jamie

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

dmbschmid

From: Woodbury, MN USA
Posts: 1
Member Since: 07/24/07
posted March 25, 2015 2:19 PM

Has this issue been resolved?
Jamie Powell (Admin)

From: Rome, NY USA
Posts: 448
Member Since: 03/13/07

Extra Support Options
Custom Application Development

posted March 25, 2015 4:14 PM

Thank you for your post. No, this issue has not yet been resolved, however it has been logged as TFS657 and will be reviewed for resolution in the next release.

Best regards,
Jamie
Reply | PowerTCP SFTP & SSH for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX