How to use Hubot behind a proxy.

You may fail to run a bot which uses http connection with Hubot if you are behind a proxy such as Squid.
Hubot behind a proxy · Issue #287 · github/hubot · GitHub
For example, you'll have following type of error messages when you run "hubot youtube me [search key words]".

events.js:72
            throw er; // Unhandled 'error' event
                      ^
Error: connect ECONNREFUSED
  at errnoException (net.js:900:11)
  at Object.afterConnect [as oncomplete] (net.js:891:19)

In this case, you might be able to solve the issue to specify proxy address and proxy port in node-scoped-http-client which is one of the wrapper libraries of Node.js's HTTP client and used by Hubot.

How to modify the source code (hubot/node_modules/scoped-http-client/src/lib/index.js) is as follows.

port = this.options.port || ScopedClient.defaultPort[this.options.protocol] || 80;
req = (this.options.protocol === 'https:' ? https : http).request({
  // port: port,
  port: 3127,           // you have to specify a proxy port.
  // host: this.options.hostname,
  host: 'localhost',   // you have to specify a proxy server address or hostname.
  method: method,
  // path: this.fullPath(),
  path: 'http://' + this.options.hostname + this.fullPath(),
  headers: headers,
  agent: this.options.agent || false
});