SSHServer not receving full file (General questions)
What is happening is that we have a wodSSH server component running on an XP machine that is listening on port 22. When it receives files from a wodSFTP component, it only receives partial files. Ie, if we are sending a 92K file, the SSHServer receives 64K. Obviously this is a magic number in file transferring. The errorcode returned is zero.
If the same file is transferred using winSCP, it arrives fine.
If the same file is transferred to a unix server, it arrives fine.
If a pause of 1/2 second is put after the file returns the done event, it transfers fine.
It appears the connection is disconnecting prematurely. I've used code directly from the examples to bypass problems with prior code written. Both exhibit the same problem. With our unix code, we always immediately use an MD5 command on the server (and the client) to ensure the file was transferred properly.
Any ideas on where to start?
Darren
Re: SSHServer not receving full file
Darren,
I assume you can prepare small (VB?) app that will contain both wodSSHServer and wodSFTP, so we can click on a button and see the problem? That would be the most convinient way - and I think it will be easy to fix. Just make sure you set it up exactly the way you use it in your product.
Re: SSHServer not receving full file
We have run the test again with the #4 example from SFTP (upload and download) and the #5 example from SSHD (SFTP Server).
If the code from both examples are used without modification, things work fine. The file is transferred correctly.
However, we are transferring files on demand from an application called from another. Therefore, we disconnect immediately after wodSFTP tells us the transfer was successful. To simluate this, in the SFTP example, we put a SFTP1.Disconnect in the DONE event. If this is placed here, an imcomplete file is transferred.
In our code we issue the putfile command then loop until the done event fires and a flag is set. We then immediately disconnect.
Regards,
Darren
Re: SSHServer not receving full file
Darren,
ok, can you send that code snippet of how you loop? Do you use Blocking mode?
Re: SSHServer not receving full file
Here is the done event:
Private Sub m_oSFTP_Done(ByVal ErrorCode As Integer, ByVal ErrorText As String)
m_dErrorCode = ErrorCode
m_bDone = True
End Sub
Putfile function:
Friend Function PutFile(p_sUserName As String, p_sPassword As String, p_sHostName As String, _
p_sPort As String, p_sLocalPath As String, p_sRemotePath As String)
On Error GoTo Err_handler
Dim nTryCount As Long
Dim sLocation As String
' connect to the host/port
sLocation = Connecting to server
Connect p_sUserName, p_sPassword, p_sHostName, p_sPort
' Control must be in connected state before it can
' transfer files
Do Until m_oSFTP.State = Connected
DoEvents
Loop
sLocation = Connected to Server
m_oSFTP.TransferMode = Binary
m_oSFTP.Blocking = False
sLocation = Trying to put file on server
m_bDone = False
m_oSFTP.PutFile p_sLocalPath, p_sRemotePath
Do Until m_bDone = True
DoEvents
Loop
DoEvents
Sleep 500 ' this makes things work
m_oSFTP.Disconnect
Exit Function
Err_handler:
m_dErrorCode = Err.Number
m_sErrorText = Location: & sLocation & - Description: & Err.Description
End Function
I've used blocking mode with the same results.
Darren