-
Notifications
You must be signed in to change notification settings - Fork 663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket connection should honor 'https_proxy' environment variable #268
Comments
Howdy! Thanks for filing this report. Could I ask a favor? I don't have a suitable firewall available for testing—since you seem to have figured out where the problem lies, could I convince you to publish your fix in a PR? This would be a lot easier than me guessing at the right fix, and passing it to you for verification and testing. |
@DEGoodmanWilson Hi, here is my patch. Feel free to use it 😺 node-slack-sdk (master) $ git diff
diff --git a/lib/clients/transports/ws.js b/lib/clients/transports/ws.js
index a62a622..f50f657 100644
--- a/lib/clients/transports/ws.js
+++ b/lib/clients/transports/ws.js
@@ -16,9 +16,11 @@ var WebSocket = require('ws');
var wsTransport = function wsTransport(socketUrl, opts) {
var wsTransportOpts = opts || {};
var wsOpts = {};
+ var proxyURL = wsTransportOpts.proxyURL || process.env.https_proxy;
- if (wsTransportOpts.proxyURL) {
- wsOpts.agent = new HttpsProxyAgent(wsTransportOpts.proxyUrl);
+ if (proxyURL) {
+ console.log("Using https proxy: " + proxyURL)
+ wsOpts.agent = new HttpsProxyAgent(proxyURL);
}
return new WebSocket(socketUrl, wsOpts); |
I am very sorry that it is annoying, but it is for your protection as much as ours. Unfortunately, I cannot accept a patch without a signed CLA either 😭 |
PR created. Please kindly review :-D |
Hi, I resubmitted the CLA again. |
Description
When we setup our
hubot-slack
behind a firewall. When starting the hubot, we sethttps_proxy
environment variable. When starting up, hubot printsLogged in as BOT of TEAMNAME
, then it silently did nothing. This is confusing.After investigation, we found that we found that slack is able to get authenticated because it uses
https_proxy
. But after that it cannot connect to websocket because it ignored thehttps_proxy
settings.In the code, we found that although there is proxy support in ws.js, but client.js simply doesn't pass proxy opts. We passed the
process.env.https_proxy
to thewsTransport
function, then hubot works correctly.It will be good if either
client.js
orws.js
could checkenv.https_proxy
and use it correctly during websocket creation.Also, during investigation we found that there is a typo in Line 21 that
wsTransportOpts.proxyUrl
should bewsTransportOpts.proxyURL
(upper case URL)Reproducible in:
{project_name} version:
OS version(s): Ubuntu 14.04
Device(s):
Steps to reproduce:
yo hubot --adapter slack
https_proxy
variableExpected result:
Actual result:
Attachments:
The text was updated successfully, but these errors were encountered: