Hubot-slack: Document starting hubot-slack with a proxy

Created on 9 Nov 2016  路  9Comments  路  Source: slackapi/hubot-slack

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Description

I have followed the guidance here and added proxy.coffee but hubot startup is hanging on loading the slack adapter before loading hubot scripts to process that configuration.

ie robot.adapter.once 'connected', loadScripts in hubot/node_modules/.bin/hubot line 166

From what I can tell, the proxiedRequestTransport from node_modules/@slack/client/lib/clients/transports/request.js is not being used on SlackClient.connect() because the options object in node_modules/hubot-slack/slack.coffee does not allow for options to be provided for proxies (there is only an option for token).

Reproducible in:

hubot version: 2.19.0
hubot-slack version: 4.2.1
@slack/client version: 3.6.0
OS version(s): ubuntu
Device(s): AWS EC2 instance

Steps to reproduce:

  1. Setup hubot with slack adapter behind a proxy server
  2. Restrict outbound traffic directly from the hubot server to only allow traffic to go through the proxy server
  3. Try to start hubot (the start command fails because the Slack adapter is unable to connect to Slack through the proxy)

Expected result:

The hubot slack adapter to respect standard HTTP_PROXY and HTTPS_PROXY environment variables and connect on hubot startup using connections through the proxy server. Otherwise use standard hubot settings to support proxies.

Actual result:

hubot start command fails because the Slack adapter is unable to connect to Slack through the proxy.

Attachments:

Script restart attempt #6 below was started with outbound traffic restricted to only allow traffic to go through the proxy server (failed hubot start). Script restart attempt #7 below opened hubot server traffic to all IP addresses on ports 80 and 443 (successful hubot start).

error: Forever detected script was killed by signal: SIGKILL
error: Script restart attempt #6
[Tue Nov 08 2016 16:36:29 GMT+0000 (UTC)] INFO Logged in as akitabot of AkitaBox
error: Forever detected script was killed by signal: SIGKILL
error: Script restart attempt #7
[Tue Nov 08 2016 16:37:13 GMT+0000 (UTC)] INFO Logged in as akitabot of AkitaBox
[Tue Nov 08 2016 16:37:13 GMT+0000 (UTC)] INFO Slack client now connected
Registered slack user with deploy perms: 1
docs

Most helpful comment

@pietvandongen - I got caught by this... You must use lower case env variable for https_proxy or this won't work.
This works https_proxy=http://myproxy:port/ bin/hubot --adapter slack
This does not: HTTPS_PROXY=http://myproxy:port/ bin/hubot --adapter slack

All 9 comments

@resteinbock @DEGoodmanWilson I have been tracking this issue with websockets respecting the environment proxy in the slack api. A fix was merged and it is already available in version v3.6.1.

Could we bump the slack client API version to v3.6.1? Thanks!

I've just freshly installed a bot, which loads version 3.6.1 of the client API and it still doesn't seem to work.

@pietvandongen - I got caught by this... You must use lower case env variable for https_proxy or this won't work.
This works https_proxy=http://myproxy:port/ bin/hubot --adapter slack
This does not: HTTPS_PROXY=http://myproxy:port/ bin/hubot --adapter slack

Further to @ojacques's observation:

|https_proxy|HTTPS_PROXY|Works?|
|---|---|---|
|Set|Not set|Yes|
|Not set|Set|No|
|Set|Set|No|

* _Set to the same value_

The startup script currently looks for https_proxy.

https://github.com/slackapi/hubot-slack/commit/0ce771c89c9f0dce6b37852cb3f84ef1bb5865fb#diff-44aca805fd3e634b2ed4f6bc2ccb0749

I feel like we should change this to uppercase, as is standard with most ENV variables.

Any movement on this?

@davidkarlsen This has been working for me for a while now when setting http_proxy and https_proxy env vars.

@rqc
For me it hangs when trying to connect the rtm web socket client. If ok why is the ticket still open? I generate my bot with yeoman

verbose: Attempting to connect via the RTM API
debug: { '0': 'connecting' }
verbose: Retrying url=https://slack.com/api/rtm.connect
verbose: Retrying url=https://slack.com/api/rtm.connect
verbose: Retrying url=https://slack.com/api/rtm.connect
verbose: Retrying url=https://slack.com/api/rtm.connect

could you list your npm's and versions?

the reason this issue wasn't closed is because we hadn't spent the time investigating whether there was a reproducible issue here. we took the time to conduct several tests today and were able to successfully connect using a proxy. i'll be turning this into a documentation issue because we should document this feature and how its expected to work.

all you need to do is set the https_proxy environment variable as noted above. for example:

HUBOT_SLACK_TOKEN=xoxb-YOUR-TOKEN-HERE https_proxy="http://localhost:8888" ./bin/hubot --adapter slack

Was this page helpful?
0 / 5 - 0 ratings