FTP upload problem

1,499 views
Skip to first unread message

Ken C

unread,
Apr 15, 2012, 10:35:40 AM4/15/12
to weewx...@googlegroups.com
I'm having trouble with weewx's FTP report. Here's a snip of what I see in the logs:

Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: attempt #1. Failed uploading /tmp/monthradiation.png. Reason: (32, 'Broken pipe')
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: attempt #2. Failed uploading /tmp/monthradiation.png. Reason: (32, 'Broken pipe')
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: Failed to upload file /tmp/monthradiation.png
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: attempt #1. Failed uploading /tmp/yearradiation.png. Reason: (32, 'Broken pipe')
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: attempt #2. Failed uploading /tmp/yearradiation.png. Reason: (32, 'Broken pipe')
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: Failed to upload file /tmp/yearradiation.png
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: attempt #1. Failed uploading /tmp/weekbarometer.png. Reason: (32, 'Broken pipe')
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: attempt #2. Failed uploading /tmp/weekbarometer.png. Reason: (32, 'Broken pipe')
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: Failed to upload file /tmp/weekbarometer.png
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: Got error while attempting to make remote directory /tmp/backgrounds
Apr 15 10:02:05 weatherserver weewx[816]:      ****  Error:
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: Got error while attempting to make remote directory /tmp/backgrounds
Apr 15 10:02:05 weatherserver weewx[816]:      ****  Error:
Apr 15 10:02:05 weatherserver weewx[816]: ftpupload: Unable to create remote directory /tmp/backgrounds
Apr 15 10:02:06 weatherserver weewx[816]: reportengine: Caught exception <type 'exceptions.IOError'> in FtpGenerator; Unable to create remote directory /tmp/backgrounds.
Apr 15 10:02:11 weatherserver weewx[816]: ftpupload: attempt #2. Failed uploading /tmp/daytempchill.png. Reason: timed out
Apr 15 10:02:11 weatherserver weewx[816]: ftpupload: Failed to upload file /tmp/daytempchill.png
Apr 15 10:02:32 weatherserver weewx[816]: filegenerator: generated 6 'toDate' files in 115.67 seconds
Apr 15 10:02:45 weatherserver weewx[816]: ftpupload: attempt #1. Failed uploading /tmp/daybarometer.png. Reason: timed out
Apr 15 10:03:08 weatherserver weewx[816]: genimages: Generated 22 images in 35.37 seconds
Apr 15 10:03:17 weatherserver weewx[816]: ftpupload: attempt #2. Failed uploading /tmp/daybarometer.png. Reason: timed out
Apr 15 10:03:17 weatherserver weewx[816]: ftpupload: Failed to upload file /tmp/daybarometer.png
Apr 15 10:03:48 weatherserver weewx[816]: ftpupload: attempt #1. Failed uploading /tmp/weekwind.png. Reason: timed out
Apr 15 10:03:50 weatherserver weewx[816]: ftpupload: attempt #1. Failed uploading /tmp/mobile.html. Reason: timed out
Apr 15 10:04:21 weatherserver weewx[816]: ftpupload: attempt #2. Failed uploading /tmp/weekwind.png. Reason: timed out
Apr 15 10:04:21 weatherserver weewx[816]: ftpupload: Failed to upload file /tmp/weekwind.png
Apr 15 10:04:23 weatherserver weewx[816]: ftpupload: attempt #2. Failed uploading /tmp/mobile.html. Reason: timed out
Apr 15 10:04:23 weatherserver weewx[816]: ftpupload: Failed to upload file /tmp/mobile.html
etc...

First thing I checked was that I could manually FTP at the command line with the same credentials, server and path specified in weewx.conf. That worked fine, I could transfer (a weather graph image from public_html on the weewx server)  to the remote server.

I tried playing setting a longer time for server_timeout in weewx.conf, 30 seconds, then a minute, but that didn't fix it. The weewx server and weather station ISS and leaf/soil station are at the cottage, and everything runs over a slow sattelite connection, so I thought it was timing out from the slow transfer rate. But then I wouldn't have been able to manually transfer the files. Also, we have an standalone IP camera that uploads 300Kb files every ten minutes to the same FTP server, and it doesn't have any problems.

I tried changing from passive to active in weewx.conf, but no difference. I tried changing destination server path (fyi, it's not jailed).

I'm running vsftpd on the remote server. I checked the xferlog, nothing shows up for the weewx transfer attempts, but I can see all the sucessful uploads from the IP camera and from when I manually FTPed files up from the weewx server.

Any ideas or suggestions?

Thanks,
Ken

Ken C

unread,
Apr 15, 2012, 10:38:42 AM4/15/12
to weewx...@googlegroups.com
I should have added that this is the first time I'm using the FTP report in weewx, it's not a situation where it was working before and then stopped working.

Thomas Keffer

unread,
Apr 15, 2012, 11:03:35 AM4/15/12
to weewx...@googlegroups.com
This is nothing I've seen before, but I suspect you've put your finger on the problem: satellite latency.

Something to try:

Go into the file bin/weeutil/ftpupload.py and make a change. Change the line 

ftp_server = ftplib.FTP(self.server)

so it reads

ftplib.FTP.set_debuglevel(2)
ftp_server = ftplib.FTP(self.server, timeout=20)

Run weewx from the command line and see what it says. 

Alternatively, rather than change two things at once, you could just add the debug command and leave out the timeout, just to be sure we're closing in on the problem.

-tk



--
You received this message because you are subscribed to the Google Groups "Weewx Weather Station Discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msg/weewx-user/-/-P8U-_-K2HwJ.
To post to this group, send email to weewx...@googlegroups.com.
To unsubscribe from this group, send email to weewx-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/weewx-user?hl=en.



--
Thomas Keffer

kef...@threefools.org
+1 541-386-8891 (h)
+1 541-490-9507 (c)
Skype: tkeffer

Ken C

unread,
Apr 15, 2012, 11:35:10 AM4/15/12
to weewx...@googlegroups.com
Tom,

Apr 15 11:18:45 weatherserver weewx[1352]: reportengine: Caught unrecoverable exception in generator weewx.reportengine.FtpGenerator
Apr 15 11:18:45 weatherserver weewx[1352]:         ****  __init__() got an unexpected keyword argument 'timeout'
Apr 15 11:18:45 weatherserver weewx[1352]:         ****  Traceback (most recent call last):
Apr 15 11:18:45 weatherserver weewx[1352]:         ****    File "/home/weewx/bin/weewx/reportengine.py", line 130, in run
Apr 15 11:18:45 weatherserver weewx[1352]:         ****      obj.start()
Apr 15 11:18:45 weatherserver weewx[1352]:         ****    File "/home/weewx/bin/weewx/reportengine.py", line 149, in start
Apr 15 11:18:45 weatherserver weewx[1352]:         ****      self.run()
Apr 15 11:18:45 weatherserver weewx[1352]:         ****    File "/home/weewx/bin/weewx/reportengine.py", line 178, in run
Apr 15 11:18:45 weatherserver weewx[1352]:         ****      N = ftpData.run()
Apr 15 11:18:45 weatherserver weewx[1352]:         ****    File "/home/weewx/bin/weeutil/ftpupload.py", line 69, in run
Apr 15 11:18:45 weatherserver weewx[1352]:         ****      ftp_server = ftplib.FTP(self.server, timeout=20)
Apr 15 11:18:45 weatherserver weewx[1352]:         ****  TypeError: __init__() got an unexpected keyword argument 'timeout'
Apr 15 11:18:45 weatherserver weewx[1352]:         ****  Generator terminated...

I'm running Python v2.5.2 on Debian Linux 2.6.24.4 #1 Wed Jun 8 10:37:39 MST 2011 armv4l GNU/Linux

Ken C

unread,
Apr 15, 2012, 11:43:25 AM4/15/12
to weewx...@googlegroups.com
Ah, ftplib timeout parameter was added in Python 2.6...
 

Thomas Keffer

unread,
Apr 15, 2012, 11:48:01 AM4/15/12
to weewx...@googlegroups.com
Oops. The "timeout" keyword was not introduced until V2.6.

Still, try it without the timeout, but with the debug statement, and see what it says.

-tk

--
You received this message because you are subscribed to the Google Groups "Weewx Weather Station Discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msg/weewx-user/-/p1UHSexU8p0J.

To post to this group, send email to weewx...@googlegroups.com.
To unsubscribe from this group, send email to weewx-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/weewx-user?hl=en.

Ken C

unread,
Apr 15, 2012, 12:07:06 PM4/15/12
to weewx...@googlegroups.com
Here's what I get when I add the debug line:

Apr 15 12:04:35 weatherserver weewx[1479]:         ****  Traceback (most recent call last):
Apr 15 12:04:35 weatherserver weewx[1479]:         ****    File "/home/weewx/bin/weewx/reportengine.py", line 130, in run
Apr 15 12:04:35 weatherserver weewx[1479]:         ****      obj.start()
Apr 15 12:04:35 weatherserver weewx[1479]:         ****    File "/home/weewx/bin/weewx/reportengine.py", line 149, in start
Apr 15 12:04:35 weatherserver weewx[1479]:         ****      self.run()
Apr 15 12:04:35 weatherserver weewx[1479]:         ****    File "/home/weewx/bin/weewx/reportengine.py", line 178, in run
Apr 15 12:04:35 weatherserver weewx[1479]:         ****      N = ftpData.run()
Apr 15 12:04:35 weatherserver weewx[1479]:         ****    File "/home/weewx/bin/weeutil/ftpupload.py", line 69, in run
Apr 15 12:04:35 weatherserver weewx[1479]:         ****      ftplib.FTP.set_debuglevel(2)
Apr 15 12:04:35 weatherserver weewx[1479]:         ****  TypeError: unbound method set_debuglevel() must be called with FTP instance as first argument (got int instance instead)


Thomas Keffer

unread,
Apr 15, 2012, 12:16:52 PM4/15/12
to weewx...@googlegroups.com
Oh, yeah. Trouble with doing remote debugging!

Now that I look at the code, I see that there is already a "debug" statement in there, which has been commented out. All you have to do is uncomment it. It's at about line 70. So, now it reads:

ftp_server = ftplib.FTP(self.server)
ftp_server.set_debuglevel(1)  # Or '2' for more information
ftp_server.login(self.user, self.password)

As indicated, the debug level can be set to '1' or '2'. I would start with '2'. If it's an overwhelming about of information, switch to '1'.

-tk

--
You received this message because you are subscribed to the Google Groups "Weewx Weather Station Discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msg/weewx-user/-/F5E_i4y0bZQJ.

To post to this group, send email to weewx...@googlegroups.com.
To unsubscribe from this group, send email to weewx-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/weewx-user?hl=en.

Ken C

unread,
Apr 15, 2012, 1:09:25 PM4/15/12
to weewx...@googlegroups.com
debuglevel(2) doesn't seem to yield any more information. Here's the latest output:

Apr 15 13:04:49 weatherserver weewx[1578]: ftpupload: attempt #1. Failed uploading /tmp/weekwind.png. Reason: timed out
Apr 15 13:05:21 weatherserver weewx[1578]: ftpupload: attempt #2. Failed uploading /tmp/weekwind.png. Reason: timed out
Apr 15 13:05:21 weatherserver weewx[1578]: ftpupload: Failed to upload file /tmp/weekwind.png
Apr 15 13:05:53 weatherserver weewx[1578]: ftpupload: attempt #1. Failed uploading /tmp/yeartempdew.png. Reason: timed out
Apr 15 13:06:25 weatherserver weewx[1578]: ftpupload: attempt #2. Failed uploading /tmp/yeartempdew.png. Reason: timed out
Apr 15 13:06:25 weatherserver weewx[1578]: ftpupload: Failed to upload file /tmp/yeartempdew.png
Apr 15 13:06:59 weatherserver weewx[1578]: ftpupload: attempt #1. Failed uploading /tmp/yearwinddir.png. Reason: timed out
Apr 15 13:07:31 weatherserver weewx[1578]: ftpupload: attempt #2. Failed uploading /tmp/yearwinddir.png. Reason: timed out
Apr 15 13:07:31 weatherserver weewx[1578]: ftpupload: Failed to upload file /tmp/yearwinddir.png

Ken
-tk

To unsubscribe from this group, send email to weewx-user+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/weewx-user?hl=en.
Message has been deleted
Message has been deleted

Ken C

unread,
Apr 15, 2012, 7:49:18 PM4/15/12
to weewx...@googlegroups.com
Tom,

I've tried some tests scripts with the paramiko SSH/SFTP Python module, and can successfully upload files to the web server from the weewx server over the sat connection. I'm going to try and modify the ftpupload.py to use paramiko. Will let you know if it works. I'd much rather use SFTP anyways.

Cheers,
Ken


On Sunday, 15 April 2012 12:16:52 UTC-4, Tom Keffer wrote:
-tk

To unsubscribe from this group, send email to weewx-user+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/weewx-user?hl=en.

Thomas Keffer

unread,
Apr 15, 2012, 9:16:05 PM4/15/12
to weewx...@googlegroups.com
OK, let me know how that goes.

Incidentally, the output of the FTP debug is written to stdout, not the log. That's why you have to run it on the command line.

-tk

To view this discussion on the web visit https://groups.google.com/d/msg/weewx-user/-/SnAXChI7jxoJ.

To post to this group, send email to weewx...@googlegroups.com.
To unsubscribe from this group, send email to weewx-user+...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/weewx-user?hl=en.

Thomas Keffer

unread,
Apr 15, 2012, 9:17:52 PM4/15/12
to weewx...@googlegroups.com
I should add:

I looked at paramiko when I was writing weewx. It's good stuff, but I didn't want to add another package dependency for what's really a small part of the weewx functionality. 

If that doesn't work, send me the ssh info and I'll take a look.

-tk

Ken C

unread,
Apr 15, 2012, 11:06:09 PM4/15/12
to weewx...@googlegroups.com
Tom,

I'm up and running with the SFTP / Paramiko rewrite. Thanks for the help troubleshooting, I'm still not 100% sure why the FTP was failing, sat latency most likely, but I'm not going to spend any more time trying to figure it out now.

Cheers,
Ken

Ken C

unread,
Apr 15, 2012, 11:07:44 PM4/15/12
to weewx...@googlegroups.com
And it turns out that even the latest version of Paramiko requires a patch job (which I only found about on another forum) since it doesn't quite work out of the box... 

Ken C

unread,
Apr 17, 2012, 10:16:19 AM4/17/12
to weewx...@googlegroups.com
It's been going for a full day now, SFTPing the site over the sat connection every 15 minutes, not a single timeout! Paramiko for the win! :)

peter.lawre...@gmail.com

unread,
Jun 23, 2013, 2:04:48 AM6/23/13
to weewx...@googlegroups.com
Just following this oldish thread - I need to use sftp rather than ftp due to security issues on the web server I am trying to get to. Would your modifications Ken make this possible?

Jan Valkenier

unread,
Jun 4, 2014, 3:46:44 AM6/4/14
to weewx...@googlegroups.com

I'm having exactly the same problem since a few days. FTP yields a timeout in the logs, and every now and then a broken pipe. However, filzilla connects over the same connection and with the same credentials whithout trouble. Whatś going on?



Op zondag 23 juni 2013 08:04:48 UTC+2 schreef Peter Jackson:

Thomas Keffer

unread,
Jun 6, 2014, 8:49:11 AM6/6/14
to weewx-user
Are you running over a satellite connection like the original poster?

-tk


--
You received this message because you are subscribed to the Google Groups "Weewx user's group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jan Valkenier

unread,
Jun 20, 2014, 6:29:53 AM6/20/14
to weewx...@googlegroups.com
No, It's a fixed line connection.

Op vrijdag 6 juni 2014 14:49:11 UTC+2 schreef Tom Keffer:

Jan Valkenier

unread,
Jun 29, 2014, 9:45:41 AM6/29/14
to weewx...@googlegroups.com

From pyhon I get this:

Python 2.7.3 (default, Jan 13 2013, 11:20:46) 

[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ftplib import FTP
>>> ftp = FTP('ftp.***.nl')

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/ftplib.py", line 117, in __init__
self.connect(host)
File "/usr/lib/python2.7/ftplib.py", line 135, in connect
self.welcome = self.getresp()
File "/usr/lib/python2.7/ftplib.py", line 217, in getresp
raise error_temp, resp
ftplib.error_temp: 421 There are too many connections from your internet address

Is it due to a limitiation on the FTP-server? Can I reduce the number of connections?



Op vrijdag 20 juni 2014 12:29:53 UTC+2 schreef Jan Valkenier:

Jim Perry

unread,
Jan 27, 2016, 12:00:57 AM1/27/16
to weewx-user
So I just resolved my problem with FTP uploads failing. It turns out I had recently enabled wunderground's "rapidfire". Disabling that fixed my uploads immediately.
Reply all
Reply to author
Forward
0 new messages