We dug a little deeper and the hang seems to be in the SSH library, not SFTP. It occurs when the amount of data sent exceeds the packet size defined by the remote server (it was roughly 4kb for Tectia). This triggers some buffering in the Perl SSH library. Changing the COPY_SIZE means you're basically doing the buffering yourself. Maybe some sample cases will make it clearer:
* COPY_SIZE=8kb, file size=3kb:
3kb string put with Net::SFTP
Net::SFTP examines COPY_SIZE: 8kb
Net::SFTP sends 3kb to Net::SSH
Net::SSH examines Tectia packet size: 4kb
Net::SSH sends 3kb
*success*
* COPY_SIZE=8kb, file size=10kb:
10kb string put with Net::SFTP
Net::SFTP examines COPY_SIZE: 8kb
Net::SFTP sends first 8kb of 10kb to Net::SSH
Net::SSH examines Tectia packet size: 4kb
Net::SSH buffering triggered
Net::SSH sends first 4kb of 8kb
*Net::SSH hangs waiting for Tectia response*
* COPY_SIZE=4kb, file size=3kb
...same as first
*success*
* COPY_SIZE=4kb, file size=10kb
10kb string put with Net::SFTP
Net::SFTP examines COPY_SIZE: 4kb
Net::SFTP sends first 4kb of 10kb to Net::SSH
Net::SSH examines Tectia packet size: 4kb
Net::SSH sends 4kb
Net::SFTP sends next 4kb of 10kb to Net::SSH
Net::SSH examines Tectia packet size: 4kb
Net::SSH sends 4kb
Net::SFTP sends final 2kb of 10kb to Net::SSH
Net::SSH examines Tectia packet size: 4kb
Net::SSH sends 2kb
*success*
It appears there's an issue with the interaction between Perl SSH and Tectia 5.0.x when multiple data packets need to be sent. We've only encountered this problem when using this specific SFTP/SSH library and this specific Tectia server (4.0.x seems fine), so we don't know what's up. We'll probably end up using Net::SFTP::Foreign.
(2)
]
