Please attach a full debug and session log files showing the problem (using the latest version of WinSCP).
To generate log files, set
Session.SessionLogPath. Submit the log with your post as an attachment. You may want to remove data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
Actually, I changed my program so that it opens and closes sessions for every single file to transfer. Since it has to find among numbers of files those to be uploaded to the remote server, the elapsed time between two transfers could be long. Increasing the timeout option (up to 2 hours) didn't fix the problem so I assumed that opening/closing sessions could fix the problem of the remote server closing unexpectedly the connection. So far, it's ok.
By the way, password can be found in the debug log file at the lines beginning with "Scheduling output: [winscp> open..." and "Output: [winscp> open...".