I am developing a Slack bot (using Hubot) as well as a Rails app that will receive HTTP requests from it and process them accordingly. Basically, the high-level steps of what I want to do are like this:
I seem to have some sort of routing issue, because I get the EHOSTUNREACH
error when I try to execute this flow with both apps booted (rails s
for Rails and ./bin/hubot --adapter slack
for Hubot). I'm guessing that Hubot is unable to reach the Rails app at all.
Am I missing something here? What URL do I need to use to enable these apps to send requests to each other?
I've also tried swapping out the 127.0.0.1:3000
with localhost:3000
, but the results stayed the same.
Hubot code
module.exports = (robot) ->
robot.respond /bye/i, (res) ->
res.reply('Later alligator')
robot.logger.info 'Will proceed to clock out user'
data = JSON.stringify({
slack_user_id: res.message.user.id
})
robot.http("127.0.0.1:3000/")
.header('Content-Type', 'application/json')
.post(data) (err, resp, body) ->
if err
robot.logger.info "Encountered an error: #{err}"
else
robot.logger.info 'Successfully sent HTTP request to Rails app'
Log results when I send trigger word to bot
INFO Will proceed to clock out user
INFO Encountered an error: Error: connect EHOSTUNREACH 0.0.11.184:80 - Local (192.168.91.168:60029)
Rails server log (it's definitely port 3000)
* Listening on tcp://localhost:3000
Change the request to robot.http("http://localhost:3000")
ensuring you have the protocol at the beginning.