Based on advise from slack-ruby/slack-ruby-bot#97 I have tested the hi_web example from behind my corporate firewall and it works without issue.
However the hi_real_time example does not, even when altered to include the proxy server in the configuration. Currently the only machines on the network with the proxy are headless, so I cannot test the normal Slack client either.
Am I configuring the proxy correctly here in this code?
Log:
I, [2016-10-04T03:53:18.471691 #6660] INFO -- : post https://slack.com/api/rtm.start
D, [2016-10-04T03:53:18.471804 #6660] DEBUG -- request: Accept: "application/json; charset=utf-8"
User-Agent: "Slack Ruby Client/0.7.7"
Content-Type: "application/x-www-form-urlencoded"
I, [2016-10-04T03:53:18.875181 #6660] INFO -- Status: 200
D, [2016-10-04T03:53:18.875356 #6660] DEBUG -- response: content-type: "application/json; charset=utf-8"
content-length: "3791"
connection: "close"
access-control-allow-origin: "*"
cache-control: "private, no-cache, no-store, must-revalidate"
content-security-policy: "referrer no-referrer;"
date: "Tue, 04 Oct 2016 03:53:18 GMT"
expires: "Mon, 26 Jul 1997 05:00:00 GMT"
pragma: "no-cache"
server: "Apache"
strict-transport-security: "max-age=31536000; includeSubDomains; preload"
vary: "Accept-Encoding"
x-accepted-oauth-scopes: "rtm:stream,client"
x-content-type-options: "nosniff"
x-oauth-scopes: "identify,read,post,client,apps"
x-slack-backend: "h"
x-slack-req-id: "e43ecc1d-be89-4f3a-8a80-cac8549171a9"
x-xss-protection: "0"
x-cache: "Miss from cloudfront"
via: "1.1 9f5fd09f16a7b31d703d6acac7f88026.cloudfront.net (CloudFront)"
x-amz-cf-id: "RAOXPlWc12pUzC7CdTWc7mOi5aIfTzxwAUyNkujUneU-QHJbqAiWiA=="
D, [2016-10-04T03:53:18.888880 #6660] DEBUG -- Slack::RealTime::Concurrency::Celluloid::Socket#connect!: WebSocket::Driver::Client
E, [2016-10-04T03:55:26.196574 #6660] ERROR -- : Actor crashed!
ThreadError: Target thread must not be current thread
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-essentials-0.20.5/lib/celluloid/internals/thread_handle.rb:37:in `join'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:97:in `join'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/proxy/actor.rb:28:in `terminate'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/proxy/cell.rb:59:in `terminate'
/home/nigel/test/slack-ruby-client/lib/slack/real_time/concurrency/celluloid.rb:42:in `ensure in run_loop'
/home/nigel/test/slack-ruby-client/lib/slack/real_time/concurrency/celluloid.rb:42:in `run_loop'
/home/nigel/test/slack-ruby-client/lib/slack/real_time/concurrency/celluloid.rb:29:in `connect!'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/calls.rb:28:in `public_send'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/calls.rb:28:in `dispatch'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/call/sync.rb:16:in `dispatch'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/cell.rb:50:in `block in dispatch'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/cell.rb:76:in `block in task'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:339:in `block in task'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/task.rb:44:in `block in initialize'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/task/fibered.rb:14:in `block in create'
/usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/task/fibered.rb:35:in `terminate': task was terminated (Celluloid::TaskTerminated)
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:323:in `block in cleanup'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:321:in `each'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:321:in `cleanup'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:307:in `shutdown'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:299:in `handle_crash'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:171:in `rescue in run'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:150:in `run'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor.rb:131:in `block in start'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-essentials-0.20.5/lib/celluloid/internals/thread_handle.rb:14:in `block in initialize'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/actor/system.rb:78:in `block in get_thread'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/group/spawner.rb:50:in `block in instantiate'
from (celluloid):0:in `remote procedure call'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/call/sync.rb:45:in `value'
from /usr/local/rvm/gems/ruby-2.3.1/gems/celluloid-0.17.3/lib/celluloid/proxy/sync.rb:22:in `method_missing'
from /home/nigel/test/slack-ruby-client/lib/slack/real_time/client.rb:51:in `start!'
from hi.rb:49:in `<main>'
hi.rb :
require 'slack-ruby-client'
Slack.configure do |config|
config.token = ENV['SLACK_API_TOKEN']
config.logger = Logger.new(STDOUT)
config.logger.level = Logger::DEBUG
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end
Slack::Web::Client.config do |config|
config.user_agent = 'Slack Ruby Client/1.0'
config.proxy = 'http://10.1.1.50:8080'
end
Slack::RealTime::Client.config do |config|
config.websocket_proxy = {
origin: 'http://10.1.1.50:8080',
headers: { 'User-Agent' => 'Slack Ruby Client/0.7.7' }
}
end
client = Slack::RealTime::Client.new
client.on :hello do
puts "Successfully connected, welcome '#{client.self.name}' to the '#{client.team.name}' team at https://#{client.team.domain}.slack.com."
end
client.on :message do |data|
puts data
client.typing channel: data.channel
case data.text
when 'bot hi' then
client.message channel: data.channel, text: "Hi <@#{data.user}>!"
when /^bot/ then
client.message channel: data.channel, text: "Sorry <@#{data.user}>, what?"
end
end
client.on :close do |_data|
puts 'Connection closing, exiting.'
end
client.on :closed do |_data|
puts 'Connection has been disconnected.'
end
client.start!
Based on advise from slack-ruby/slack-ruby-bot#97 I have tested the hi_web example from behind my corporate firewall and it works without issue.
However the hi_real_time example does not, even when altered to include the proxy server in the configuration. Currently the only machines on the network with the proxy are headless, so I cannot test the normal Slack client either.
Am I configuring the proxy correctly here in this code?
Log:
hi.rb :