connection droped issue with paramiko while uploading huge files

        with paramiko.Transport((server, 22)) as transport:
            # SFTP FIXES
            transport.default_window_size = paramiko.common.MAX_WINDOW_SIZE // 2
            #transport.default_max_packet_size = paramiko.common.MAX_WINDOW_SIZE
            transport.packetizer.REKEY_BYTES = pow(2,
                                                   40)  # 1TB max, this is a security degradation!
            transport.packetizer.REKEY_PACKETS = pow(2,
                                                      40)  # 1TB max, this is a security degradation!
            # / SFTP FIXES

            transport.connect(username=username, password=pw)
            with paramiko.SFTPClient.from_transport(transport) as sftp:
                sftp.get_channel().in_window_size = 2097152
                sftp.get_channel().out_window_size = 2097152
                sftp.get_channel().in_max_packet_size = 2097152
                sftp.get_channel().out_max_packet_size = 2097152
                files = sftp.listdir()
                files = list(filter(lambda x: x.endswith(".zip"), files))
                print(files)

                if len(files) > 2:
                    for f in files:
                        target = str(dst / f)
                        print(f"Downloading {f} to {target}")
                        sftp.get(f, target)

                    for f in files:
                        sftp.remove(f)

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source