Aha, finally found the issue! The core problem is the server we are connecting to is really, REALLY slow! I have no idea why it is so slow, but with the default buffer size of 16K, it times out trying to send data to the server. I changed it to a 1K buffer size and it worked just fine.
So, in reality I don't want to change the default buffer size, but what I do need to change is the timeout. What timeout is happening during uploads that would cause problems if the SFTP server is really slow? I plan to debug the code a bit and see if I can spot it. Worst case I can work out what buffer size works with this server and force that, but in reality the proper fix is to change the library so it handles this situation correctly ...
So, in reality I don't want to change the default buffer size, but what I do need to change is the timeout. What timeout is happening during uploads that would cause problems if the SFTP server is really slow? I plan to debug the code a bit and see if I can spot it. Worst case I can work out what buffer size works with this server and force that, but in reality the proper fix is to change the library so it handles this situation correctly ...