What to do when your Internet is too slow for composer?

Like the problems I was having with Docker timeouts, I recently had problems on my slow home Internet getting PHP’s composer to build the assets for a project.

The error message contained “exceeded the timeout of 300 seconds” so it was easy to identify.

The fix, run from the terminal was:

export COMPOSER_PROCESS_TIMEOUT=1500

Where the number is the number of seconds before a composer operation timesout.  This fix is temporary, for a permanent solution have a look at how to make environment variables persist.

What to do when your rural high speed Internet is too slow to use Docker?

On my mid-2010 MacBook Pro I was trying to get Docker running to experiment with. It isn’t quite modern enough to run Docker for Mac because of an incompatible CPU.

I was able to get things running though by installing Docker Toolbox which puts the Docker daemon inside a VirtualBox VM. While trying to pull down an image to build a container via docker pull the command would fail and I would get the error message:

unauthorized: authentication required

This seemed weird, I’ve never had that problem on my work machines. These are public images, why would I need to be authorized? What could be the difference? The fact that the failure happened after some of the larger files were downloading made me think that something was timing out. It seems that there is token authorization happening during the download process and they are expiring. And these downloads were much, much slower on my home 2Mbps connection compared to 100Mbps at the office.

Some Googling pointed to an option for the Docker daemon that may help:

–max-concurrent-downloads

So in the case of having the Docker daemon on a vm, I used the docker-machine command to SSH to the daemon to put this extra config into a daemon.json file that is parsed when the daemon starts.

First, from your OS terminal:

docker-machine ssh

Then when you are logged into Docker VM:

echo ‘{“max-concurrent-downloads”:25}’ | sudo tee /etc/docker/daemon.json

This ensures that all of the files are downloaded concurrently, starting to download before what I assume is the token expiring. You will need to restart the daemon, I did it from directly inside the vm with

sudo /etc/init.d/docker restart

While our slow “high speed ultra” Internet has been an annoyance with poor quality audio and video and slow downloads, it has never caused something to absolutely not work without modification. This is a demonstrable example of how the poor quality of PEI’s rural Internet can impact employment and innovation.