rsync/scp "Connection reset by peer" problems

Tuesday, July 20 2010 @ 10:32 AM UTC

Contributed by: Admin

After the ADSL line has been updated by our provider, we got a lot of "Connection reset by peer" problems when retrieving backups from a remote server using rsync and scp … but the quality of the line doesn't seem to be the problem… any idea ?

When your local computer can't catch-up decrypting and writing the received data down to the hard disk, it sends some messages (ICMP source quench - type 4 messages) to remote host to ask it to slow down…

Some Linux boxes doesn't respect that, and continue to send to full speed… the only way for the local computer to solve the race condition is to give up…

So probably the new ADSL line bandwidth is too high for your computer to catch up with the processing and writing of the encrypted stream… in other words our new line is too good… for your computer…

The easiest solution is to modify your scripts and add "--bwlimit=$MAXKBS" to your rsync lines and "-l $MAXKBS" to your scp ones. (see man rsync and man scp for more info).

With MAXKBS being defined at top of your scripts (or sourced from a common location…) and set it to a lower value than the max bandwidth of your ADSL line.

You will have to do some testing to find the right one for your configuration since it's also depends on your computer CPU speed and quality of the hard disk I/O.