# Strange problems with net/ftp in Rails

**URL:** <https://www.ruby-forum.com/t/strange-problems-with-net-ftp-in-rails/59531>\
**Category:** Rails\
**Created:** [May 3, 2006, 10:13pm UTC](https://www.ruby-forum.com/t/strange-problems-with-net-ftp-in-rails/59531 "2006-05-03T22:13:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigbrother2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@bigbrother2](https://www.ruby-forum.com/u/bigbrother2)\
**Post date:** [May 3, 2006, 10:13pm UTC](https://www.ruby-forum.com/t/strange-problems-with-net-ftp-in-rails/59531/1 "2006-05-03T22:13:50Z")

</div>

Lately I’ve been having a very strange problem with my Rails app  
running on TextDrive. Part of its job is to send files to a remote  
server, using net/ftp. This has always worked fine, but in the last  
week or two, I’ve had huge problems sending them to servers at A Small  
Orange (another hosting company). Not all the time, but some of the  
time. Weird.

What happens is that the first file to be transferred just hangs.  
Usually, the whole batch goes over, no problem. But lately, some sites  
will start the transfer of the first file, and hang. It creates a file  
on the destination server, but it’s a zero byte file.

I make a connection and login:

@connection = Net::FTP.new @website.site\_ftp  
@connection.login( @website.username, @website.password )

I then change to the right folder and send the file:

chdir remote\_path  
@connection.putbinaryfile local, remote\_file

And the error is raised on that last line - just a TransferError from  
the net/ftp library, and a zero-byte file after hanging for about 30  
seconds.

Can anyone offer any suggestion at all? Bear in mind this has worked  
fine with a great number of hosts, even this problematic host until  
about a week ago. I’ve contacted the admin of ASO and he suggested  
that I might want to try “changing between the PASV and PORT  
connection methods” but I’m not sure how to do this with net/ftp, or  
if it will break my other sites using this app. What should I try  
next?
