# Pkg upgrade seems to fail when using a bandwidth limited internet connection.



## HungryMan2019 (Aug 3, 2019)

I am new to the forums, but not to FreeBSD - please be kind. 

I am using a Verizon Hotspot via iPhone/iPad as my internet connection.  It is connected via USB.  Everything works marvelously when my Hotspot is serving full bandwidth, but Verizon throttles the Hotspot bandwidth down to approx. 600 kbps at a certain amount of Hotspot usage.

Package upgrades work fine when I have full bandwidth.  But with lower bandwidth I get the dreaded error:

```
pkg: cached package XXXXXXXXXXXXXX size mismatch, cannot continue
```

That error happens with larger files that are downloaded during the package upgrade process.

I have searched this forum and tried about every sensible options to try and fix this issue.  The thing I have resorted to is locking each package as they error out during the upgrade process.  This is very tedious.


Is there some pkg or FreeBSD option or configuration parameter I can set?
Does anyone have any idea why it fails to download large files on a low bandwidth connection?
It almost seems to me that the remote side of the download is timing out my download.  Does anyone know if that could be true?

Thanks in advance for your assistance!


----------



## SirDice (Aug 5, 2019)

Clean your locally cached packages first using `pkg clean` or `pkg clean -a`.



HungryMan2019 said:


> Does anyone have any idea why it fails to download large files on a low bandwidth connection?


The transfer might time-out because it's so slow. 

There are  few settings you can try:

```
FETCH_RETRY: integer
                      Number of times to retry a failed fetch of a file.
                      Default: 3.

     FETCH_TIMEOUT: integer
                      Maximum number of seconds to wait for any one file to
                      download from the network, either by SSH or any of the
                      protocols supported by fetch(3) functions.  Default: 30.
```
See pkg.conf(5).


----------



## KBK (Aug 5, 2019)

If SirDice' advice is not working try to use your ISP's HTTP proxy.

Get the ISP' proxy IP then like root and set temporally the proxy with:

setenv HTTP_PROXY http://XXX.XXX.XXX.XXX:8080

Then: 
  pkg update -f
  pkg upgrade


----------



## HungryMan2019 (Aug 7, 2019)

SirDice said:


> Clean your locally cached packages first using `pkg clean` or `pkg clean -a`.
> 
> 
> The transfer might time-out because it's so slow.
> ...



Thank you for the advice.  I have tried those things, both the pkg cleans and setting the FETCH_TIMEOUT and FETCH_RETRY values.


----------



## HungryMan2019 (Aug 7, 2019)

KBK said:


> If SirDice' advice is not working try to use your ISP's HTTP proxy.
> 
> Get the ISP' proxy IP then like root and set temporally the proxy with:
> 
> ...


Thank you for the advice.  That is something that I have not tried.  Since I am using my Hotspot on my iPhone, my ISP is Verizon, I am not sure what proxy IP to use.  I will see if my Google Fu can figure that out.


----------



## HungryMan2019 (Aug 8, 2019)

Pkg does not seem to use the FETCH_TIMEOUT and FETCH_RETRY settings.  The timeouts I am experiencing seem to be on the host side, not on my side of the transfer, like the hosts just give up on the transfer.

I am currently looking at another option.  Pkg has the ability to use plug-ins.  There does not seem to be any documentation on writing a plug-in, that I can find.  There is only one example I have found so far, the ‘provides’ plug-in.

If I can write a plug-in to use ‘wget’ for upgrades, it may provide me with a more resilient way to download, when I have a slow connection.


----------

