shell-bot icon indicating copy to clipboard operation
shell-bot copied to clipboard

"node server" bahind a corporate web proxy

Open sebasolla opened this issue 7 years ago • 6 comments

Hi!, I'm getting the following error and I guess is because its trying to do a direct connection instead of using the https_proxy,

Couldn't load the configuration file, starting the wizard.

First, enter your bot API token: xxxxxxxxxx NetworkError: Error: connect ECONNREFUSED 149.154.167.220:443

Any idea?

sebasolla avatar Mar 08 '18 12:03 sebasolla

Botgram currently doesn't support proxying. But apparently it wouldn't be very difficult to add, using this module. If you want to try it, npm install https-proxy-agent and then do the following modifications in server.js:

-var bot = botgram(config.authToken);
+var bot = botgram(config.authToken, { agent: new (require('https-proxy-agent'))(process.env.https_proxy) });

And the following in lib/wizard.js:

-        var bot = botgram(token);
+        var bot = botgram(token, { agent: new (require('https-proxy-agent'))(process.env.https_proxy) });

mildsunrise avatar Mar 11 '18 18:03 mildsunrise

you are a genius!! It works like a charm!

Thank you so much

sebasolla avatar Mar 14 '18 21:03 sebasolla

Glad it worked :) I'm reopening the issue, since I'd like to incorporate this into the code someday.

mildsunrise avatar Mar 15 '18 23:03 mildsunrise

socks5 proxy:

var bot = botgram(config.authToken,
                 {agent: new (require('socks5-https-client/lib/Agent'))(
                   {"socksHost": "proxy_host",
                    "socksUsername": "user",
                    "socksPassword": "password",
                    "socksPort": 1080})
                  });

avissian avatar Apr 16 '18 15:04 avissian

I'm reopening the issue, since I'd like to incorporate this into the code someday.

https://github.com/avissian/shell-bot/commit/e4285bee13f7951ae7ddcf07ee16e86c9bf8e72e

avissian avatar Apr 16 '18 15:04 avissian

It'd be ideal if the bot could inherit proxy settings from the https_proxy environment variable. My code snippet works for http: and https: proxies, but not for SOCKS proxies... I'll try to merge everything when I have time.

mildsunrise avatar Apr 19 '18 21:04 mildsunrise