net-ssh / net-sftp

Pure Ruby implementation of an SFTP (protocols 1-6) client.
http://net-ssh.github.io/
MIT License
288 stars 131 forks source link

Error: Connection reset by peer - recvfrom(2) #67

Open dakingdom opened 7 years ago

dakingdom commented 7 years ago

Push of files to a remote via ruby net-SFTP causes "Connection reset by peer - recvfrom(2)" error . Pulling of remote of files is fine.

Found out our routers intrusion detection and prevention was causing this error trying to stop this type of venerability: SSH_EVENT_RESPOVERFLOW.

This does effect Linux command line scp pushes too. scp pulls are also fine.

It seems to occur on larger file sizes.

I thought I would report this as an issue to help others debug "Connection reset by peer - recvfrom(2)".

wakproductions commented 6 years ago

I'm getting the same error message, but uploading via FileZilla SFTP client works just fine. @dakingdom was the intrusion detection problem on the FTP server side or the local network you were uploading from?

dakingdom commented 6 years ago

The dropping of the transfer was either coming into our local network or within our local network. Always in the uploading direction. I tested it with scp and a large file. In this case a large file would be in the 200MB or larger range. Smaller files than that was not a problem. Sorry I guess, my reference frame for large file should have been clearer.

wakproductions commented 6 years ago

I think I resolved the issue. Previously I was using code similar to this to perform the upload:

Net::SFTP.start(...) do |sftp|
sftp.file.open(destination, 'w') do |handle|
  handle.puts builder.to_xml
end

Seems to be working when I do it this way:

Net::SFTP.start(...) do |ftp|
   ftp.upload(StringIO.new(generated_file.attachment.download), destination)
end
SpringsTea commented 2 years ago

I am having this issue as well, but it's very sporadic. I have a bare basic implementation.

@con = Net::SFTP.start(@@host, @@username, :password => @@password)
@con.upload!(filepath, destination)

I had this running like this for several years when suddenly this year it started throwing this error. But not all the time, only sometimes. Sometimes it works with no issue. I've talked to my sftp host and they tell me there is no problem on their end. I'm transferring xml files and images in the < 5MB range. Any troubleshooting advice is appreciated.