I'm trying to connect to my Relayr MQTT broker, but my server is behind a proxy. Unfortunately the ./core/io/10-mqtt.js file don't check if an environment variable (http_proxy or HTTP_PROXY) is set and use it.
// check if proxy is set in env
var prox;
if (process.env.http_proxy != null) { prox = process.env.http_proxy; }
if (process.env.HTTP_PROXY != null) { prox = process.env.HTTP_PROXY; }
if (prox) {
// Set BrokerUrl wss:// for mqtt connection with proxy. E.g. in node_modules/mqtt/examples/wss/client_with_proxy.js
this.brokerurl = 'wss://'+ this.broker + ":" + this.port;
var parsedUrl = url.parse(this.brokerurl);
var proxyOpts = url.parse(prox);
// true for wss
proxyOpts.secureEndpoint = parsedUrl.protocol ? parsedUrl.protocol === 'wss:' : true;
// Set Agent for wsOption in MQTT
var agent = new HttpsProxyAgent(proxyOpts);
node.options.wsOptions = {
agent: agent
}
}
So I define the above code in my 10-mqtt.js to connect to my MQTT broker. I used t
he packages url(https://www.npmjs.com/package/url) and https-proxy-agent(https://www.npmjs.com/package/https-proxy-agent). I already forked the repo, committed the code, checked grunt tests and of course my own tests.
Is there any plan to add proxy settings for MQTT like above in the next release? If possible can I do a pull request?