UPDATED Please read: SSH/SFTP client issue
Posted: Tue 21 May 2019 19:30
This is on Linux with FPC 3.0.4
see sample code below, this is connecting to a python Paramiko sftp server (latest version)
I have to have a sleep(100) before the ssh client disconnect and if I do the SFTP disconnect it raises a error:
00000000004F0BAC 4889d8 mov %rbx,%rax
00000000004F0BAF 488b00 mov (%rax),%rax
00000000004F0BB2 ff9040010000 callq *0x140(%rax)
00000000004F0BB8 4189c4 mov %eax,%r12d
00000000004F0BBB 4183fc00 cmp $0x0,%r12d
00000000004F0BBF 7f45 jg 0x4f0c06 <SCVIO$_$TCRVIO_$__$$_ENDRECEIVE$ISCASYNCRESULT$$LONGINT+278>
00000000004F0BC1 488b7b28 mov 0x28(%rbx),%rdi
00000000004F0BC5 e8467ef7ff callq 0x468a10 <CLASSES$_$TTHREAD_$__$$_TERMINATE>
00000000004F0BCA 48837b5000 cmpq $0x0,0x50(%rbx)
00000000004F0BCF 7435 je 0x4f0c06 <SCVIO$_$TCRVIO_$__$$_ENDRECEIVE$ISCASYNCRESULT$$LONGINT+278>
00000000004F0BD1 807b0800 cmpb $0x0,0x8(%rbx)
00000000004F0BD5 752f jne 0x4f0c06 <SCVIO$_$TCRVIO_$__$$_ENDRECEIVE$ISCASYNCRESULT$$LONGINT+278>
00000000004F0BD7 8b4b58 mov 0x58(%rbx),%ecx
00000000004F0BDA 488b5350 mov 0x50(%rbx),%rdx
00000000004F0BDE 488d3deb881a00 lea 0x1a88eb(%rip),%rdi # 0x6994d0 <VMT_$SCVIO_$$_SOCKETEXCEPTION>
00000000004F0BE5 48be0100000000000000 movabs $0x1,%rsi
00000000004F0BEF e85ceeffff callq 0x4efa50 <SCVIO$_$SOCKETEXCEPTION_$__$$_CREATE$ANSISTRING$LONGINT$$SOCKETEXCEPTION>
(I am also getting host key not verified errors randomly as well)
see sample code below, this is connecting to a python Paramiko sftp server (latest version)
I have to have a sleep(100) before the ssh client disconnect and if I do the SFTP disconnect it raises a error:
00000000004F0BAC 4889d8 mov %rbx,%rax
00000000004F0BAF 488b00 mov (%rax),%rax
00000000004F0BB2 ff9040010000 callq *0x140(%rax)
00000000004F0BB8 4189c4 mov %eax,%r12d
00000000004F0BBB 4183fc00 cmp $0x0,%r12d
00000000004F0BBF 7f45 jg 0x4f0c06 <SCVIO$_$TCRVIO_$__$$_ENDRECEIVE$ISCASYNCRESULT$$LONGINT+278>
00000000004F0BC1 488b7b28 mov 0x28(%rbx),%rdi
00000000004F0BC5 e8467ef7ff callq 0x468a10 <CLASSES$_$TTHREAD_$__$$_TERMINATE>
00000000004F0BCA 48837b5000 cmpq $0x0,0x50(%rbx)
00000000004F0BCF 7435 je 0x4f0c06 <SCVIO$_$TCRVIO_$__$$_ENDRECEIVE$ISCASYNCRESULT$$LONGINT+278>
00000000004F0BD1 807b0800 cmpb $0x0,0x8(%rbx)
00000000004F0BD5 752f jne 0x4f0c06 <SCVIO$_$TCRVIO_$__$$_ENDRECEIVE$ISCASYNCRESULT$$LONGINT+278>
00000000004F0BD7 8b4b58 mov 0x58(%rbx),%ecx
00000000004F0BDA 488b5350 mov 0x50(%rbx),%rdx
00000000004F0BDE 488d3deb881a00 lea 0x1a88eb(%rip),%rdi # 0x6994d0 <VMT_$SCVIO_$$_SOCKETEXCEPTION>
00000000004F0BE5 48be0100000000000000 movabs $0x1,%rsi
00000000004F0BEF e85ceeffff callq 0x4efa50 <SCVIO$_$SOCKETEXCEPTION_$__$$_CREATE$ANSISTRING$LONGINT$$SOCKETEXCEPTION>
(I am also getting host key not verified errors randomly as well)
Code: Select all
program sftp_send_file;
{$mode objfpc} {$H+}
uses cthreads,datamodU, sbridge10,sysutils;
var
sftp_client:tsftmod;
fullfilename:string;
basename:string;
remotename:string;
begin
if ParamCount >= 1 then
begin
fullfilename:= ParamStr(1);
basename:= extractfilename(fullfilename);
end;
sftp_client:=Tsftmod.create(nil);
try
sftp_client.ssh.HostName:='xxxxxxx.xxxxxxx.com';
sftp_client.ssh.Port:=10022;
sftp_client.ssh.User:='xxxxxxx';
sftp_client.ssh.Password:='xxxxx';
//connect ssh client
sftp_client.ssh.Connect;
if sftp_client.ssh.Connected then
try
sftp_client.sftp.Initialize;
if sftp_client.sftp.Active then
try
remotename:= format('/TO/%s',[basename]);
sftp_client.sftp.UploadFile(fullfilename,remotename,true);
finally
//sftp_client.sftp.Disconnect;
end;
finally
sleep(100);
sftp_client.ssh.Disconnect;
end;
finally
freeandnil(sftp_client);
end;
end.