Options
You can configure the Web client either globally or via the initializer.
Slack::Web::Client.configure do |config|
config.user_agent = 'Slack Ruby Client/1.0'
end
client = Slack::Web::Client.new(user_agent: 'Slack Ruby Client/1.0')
The following settings are supported.
| setting | description |
|---|---|
| token | Slack API token. |
| user_agent | User-agent, defaults to Slack Ruby Client/version. |
| proxy | Optional HTTP proxy. |
| ca_path | Optional SSL certificates path. |
| ca_file | Optional SSL certificates file. |
| endpoint | Slack endpoint, default is https://slack.com/api. |
| logger | Optional Logger instance that logs HTTP requests. |
| timeout | Optional open/read timeout in seconds. |
| open_timeout | Optional connection open timeout in seconds. |
| default_page_size | Optional page size for paginated requests, default is 100. |
| default_max_retries | Optional number of retries for paginated requests, default is 100. |
| adapter | Optional HTTP adapter to use, defaults to Faraday.default_adapter. |
You can also pass request options, including timeout and open_timeout into individual calls.
client.conversations_list(request: { timeout: 180 })
You can also control what proxy options are used by modifying the http_proxy environment variable per Net::HTTP’s documentation.
Docker on OSX seems to incorrectly set the proxy, causing Faraday::ConnectionFailed, ERROR -- : Failed to open TCP connection to : (getaddrinfo: Name or service not known). You might need to manually unset http_proxy in that case, eg. http_proxy="" bundle exec ruby ./my_bot.rb.