Skip to content

Commit

Permalink
Add support for environments with proxy servers
Browse files Browse the repository at this point in the history
DEFRA/water-abstraction-team#54

Our status page depends on sending requests to the other running apps and 3rd party services. All is fine in our Vagrant box but when we deployed to our AWS environments the requests just seemed to hang.

After some investigation inspiration hit! Our AWS environments require all requests to go through a proxy server and without support for this, our requests are getting stuck.

We tackled this same problem in [Replace existing proxy config with global-agent](DEFRA/sroc-charging-module-api#572) in the sroc-charging-module-api. In the Charging Module, we used [global-agent](https://github.com/gajus/global-agent). This intercepts all http/https requests and adds the proxy details them. Perfect!

The problem is it was last updated more than a year ago, the build is marked as failing, test coverage is low, and issues and PR's seem to be going unanswered. Our other issue is it does not recognise the lowercase versions of standard proxy env vars (`http_proxy`, `https_proxy` and `no_proxy`). It's a shame because it works seemlessly in the background.

The folks behind the request package we do use, [Got](https://github.com/sindresorhus/got), recommend a couple. We liked [hpagent](https://github.com/delvedor/hpagent/). The example was simple, it's being regularly updated, supports [keep-alive connections](https://en.wikipedia.org/wiki/HTTP_persistent_connection), and even uses [standardjs](https://standardjs.com/)!

So, this change brings in support for working behind a proxy using **hpagent**. As part of this we'll be refactoring the work of making HTTP requests into its own service. We'll also solve one of the other things we noted; the requests don't timeout if there is a problem making a connection.
  • Loading branch information
Cruikshanks committed Nov 10, 2022
1 parent 3e339ba commit 0e56e65
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 0e56e65

Please sign in to comment.