# Fetch freezes at 99%



## nickg (Aug 14, 2014)

Hi all,

I'm currently attempting to download a file using fetch, the download is quick, but when it reaches 99%, in hangs indefinitely (or until I kill the process).

Below is the console output:


```
nas4free: finch # fetch -T 60 -v ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.2-RELEASE/base.txz
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
setting passive mode
opening data connection
initiating transfer
local size / mtime: 67665920 / 1407936717
remote size / mtime: 67671964 / 1380284398
base.txz                                       99% of   64 MB  255 kBps 04m19s^C
fetch: transfer interrupted 
nas4free: finch #
```

I'm currently running the following version of NAS4Free, which is built on FreeBSD 9.2:


```
Version:     9.2.0.1 - Shigawire (revision 972)
Build date:  Mon Apr 28 02:37:05 CEST 2014
Platform OS: FreeBSD 9.2-RELEASE-p4 (kern.osreldate: 902001)
Platform:    x64-embedded on Intel(R) Core(TM)2 Duo CPU E6550 @ 2.33GHz
```

I don't think this issue is isolated:

https://forums.freebsd.org/viewtopic.php?&t=34288
http://compgroups.net/comp.unix.bsd.freebsd.misc/fetch-hangs-at-end-of-transfer-fre/2255077

Is anyone else having this issue?
Does anyone know why this is occurring?
Is it a buggy version of fetch?
Does this question belong in the FreeBSD forum? (I've also asked the same question in the NAS4Free forums - http://forums.nas4free.org/viewtopic.php?f=57&t=7110 )


----------



## nickg (Aug 16, 2014)

So, just trying some different options, (I rolled back to rev943) I don't know why I didn't try HTTP vs FTP sooner..

HTTP protocol works, FTP doesn't! I notice that there's a different local filesize for HTTP, than for FTP (am I reading the logs right?).
https://gist.github.com/nickgrealy/7f1a ... rks-log-L7

- Is Protocol the cause/solution?
- Is FTP miscalculating the local filesize, then waits indefinitely for the "rest" of the file (until server timeout)?
- Or is the FTP server, mis-reporting the filesize?
- (Just a longshot) Could the network card driver be involved/to blame somehow?

HTTP protocol works!


```
nas4free: ufs3 # fetch -T 60 -v http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.2-RELEASE/base.txz
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:80
requesting http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.2-RELEASE/base.txz
local size / mtime: 67671040 / 1380284398
remote size / mtime: 67671964 / 1380284398
base.txz                                      100% of   64 MB  451 kBps 02m26s
nas4free: ufs3 #
```
 
FTP protocol doesn't work!


```
nas4free: ufs3 # fetch -T 60 -v ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.2-RELEASE/base.txz
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
setting passive mode
opening data connection
initiating transfer
local size / mtime: 67671964 / 1380284398
remote size / mtime: 67671964 / 1380284398
base.txz                                       99% of   64 MB  418 kBps 02m38s^C
fetch: transfer interrupted
 
nas4free: ufs3 #
```


----------



## nickg (Aug 16, 2014)

Alright, I've had some time to do some more investigation. Looks like I'm only having issues with FTP, freebsd.org files > 1MB. I'm happy to chalk this up as an anomaly (ISP / FTP hosting / Corrupt file / ???).


```
# FTP iinet 1MB Works!

nas4free: ufs3 # fetch -T 60 -v http://ftp.iinet.net.au/1mb.dat
looking up ftp.iinet.net.au
connecting to ftp.iinet.net.au:80
requesting http://ftp.iinet.net.au/1mb.dat
remote size / mtime: 1048576 / 1064275740
1mb.dat                                       100% of 1024 kB  705 kBps 00m02s

# FTP freebsd 1.4MB Works!

nas4free: ufs3 # fetch -T 60 -v ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.2-RELEASE/doc.txz
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
setting passive mode
opening data connection
initiating transfer
remote size / mtime: 1442376 / 1380284412
doc.txz                                       100% of 1408 kB  361 kBps 00m04s

# FTP freebsd ~33MB Fails!

nas4free: ufs3 # fetch -T 60 -v ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.2-RELEASE/ports.txz
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
setting passive mode
opening data connection
initiating transfer
remote size / mtime: 36178396 / 1380284407
ports.txz                                      99% of   34 MB  247 kBps 02m22s^C
fetch: transfer interrupted

# FTP iinet ~62MB Works!

nas4free: ufs3 # fetch -T 60 -v http://ftp.iinet.net.au/2test.out
looking up ftp.iinet.net.au
connecting to ftp.iinet.net.au:80
requesting http://ftp.iinet.net.au/2test.out
remote size / mtime: 65535000 / 1254883627
2test.out                                     100% of   62 MB  792 kBps 01m20s
nas4free: ufs3 #
```

Thanks for any help or investigation provided. I think I can leave this issue.


----------



## youngunix (Aug 19, 2014)

Instead of wasting time on fetch(), try ftp/wget or ftp/curl and see if that fixes the problem.
`wget [url=ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.2-RELEASE/base.txz]ftp://ftp.freebsd.org/pub/FreeBSD/relea ... E/base.txz[/url]
curl -O [url=ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.2-RELEASE/base.txz]ftp://ftp.freebsd.org/pub/FreeBSD/relea ... E/base.txz[/url]`


----------



## erdos (Apr 28, 2015)

BSD newbie here and my first post.

Just want to say thanks for the info here!

I encountered the same error during installation of FreeBSD 10.1 on my 32 bit machine last night.  I used netinstall option through a USB memory stick.  During installation, the fetching of base.txz stopped at 98% and hangs indefinitely.

After some search I found this thread.  By using HTTP transfer instead of FTP, the installation went through without a hiccup.


----------

