Search code examples
pythonproxysftpparamikopysftp

how to set a time out for SFTP server connection using paramiko?


I am struggling to set timeout option for SFTP connection using paramiko library.

if i am moving 10GB file, after a period of time the process got stopped with out any error.There is no script issues. after I found the server got disconnected so only the file upload process not completed successfully.

can any one know how to set timeout parameter using paramiko SFTP client.?

script:

s3_conn = S3Connection(profile_name=dest_profile)
bucket = s3_conn.get_bucket(tgt_bucket_nm)
proxy = paramiko.proxy.ProxyCommand('/usr/bin/nc --proxy proxy_host:8080 %s %s' % (ftp_host, ftp_port) )
transport = paramiko.Transport(proxy)
transport.connect(username=ftp_username, password=ftp_password)
ftp_conn = paramiko.SFTPClient.from_transport(transport)

Could you please let me know if any one need more clarification of my question.

Thanks in advance


Solution

  • you can set the timeout for the channel using below line

    ftp_conn.get_channel().settimeout(1000) time is in seconds