Upload code... not working?

2 posts / 0 new
Last post
Geoff Riley
Geoff Riley's picture
Upload code... not working?

I've been trying to send through for a while, but I'm always getting a conversation like this:

pi@piz01:~/formulapi $ ./fpi-upload.sh 16 «Like I'd say!»
Formula.py
fpi-get-logs.sh
fpi-upload.sh
Globals.py
ImageProcessor.py
logs/
RaceCodeFunctions.py
Race.ori.py
Race.py
Settings.py
SimulationFull.py
SimulationImages.py
ZeroBorg.py
Connected to 217.36.211.159.
220-FileZilla Server 0.9.59 beta
220-Welcome to the Formula Pi code submission server.
220 Your race code should be submitted as formulapi.tar.gz in your home directo
331 Password required for fpi_16
230 Logged on
Remote system type is UNIX.
200 Type set to I
550 File not found
550 file/directory not found
local: formulapi.tar.gz remote: formulapi.tar.gz
421 Service not available, remote server has closed connection
pi@piz01:~/formulapi $ 

…and 13:00 GMT is rather close… I'd like to get in on this test. Help?

Geoff

Geoff Riley
Geoff Riley's picture
And I answer my own message…

It's all to do with firewalls and wonderful things like that.

A brief explanation of how FTP works: client and server communicate over two separate connections, a command connection that the client starts by connecting to the server, usually on the standard port number 21, and the server gives simple information back to the client in response to text commands on that connection. However, if more than a single line of information is needed—like a directory listing, or a file being transferred—then a second connection (ftp-data) is setup. The default method when the command 'put' is used is for the client to tell the server that it is opening a port ready for the server to make a connection back to the client, however, if the client is sat behind a firewall it may tell the server to use a private ip address such as 192.168.7.2 that the server cannot reach.

In most instances you will never come across this effect because the ip address assigned to your pi will have been allocated by the dhcp server running alongside the firewall and the firewall will spot the ftp session and rewrite the port address automatically with the correct address; but if your pi is attached to your pc or laptop via the USB, like mine, then it is likely that there is a secondary firewall working within your pc which doesn't do the rewriting but allows your pi to connect to the internet through your pcs connection.

The Solution:
FTP has an alternative method of making the second connection, this is called 'passive' mode and when an ftp-data connection is required the server is asked to make a connection available instead. This allows the client to make an outgoing connection to the server for the ftp-data and hence there is no problem with firewalls.

It is easy to fix, in the fpi-upload.sh and fpi-get-logs.sh files insert the command passive on a new line after the user $USER $PASS.

Hope that helps anyone that has had a similar problem to me.

Geoff

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Syntax highlight code surrounded by the <pre class="brush: lang">...</pre> tags, where lang is one of the following language brushes: bash, cpp, perl, python.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Comment Images
Files must be less than 10 MB.
Allowed file types: png gif jpg jpeg.
Comment Attachments
Files must be less than 10 MB.
Allowed file types: txt pdf nfo doc docx rtf jpg png gif bmp zip tar gz csv xls.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.