Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Heroku] Receiving forbidden request when I don't set a fixie proxy and internal error if a set it as endpoint #32

Closed
caherrerapa opened this issue Aug 16, 2016 · 1 comment

Comments

@caherrerapa
Copy link

caherrerapa commented Aug 16, 2016

I'm trying to make it work using heroku. The message is received correctly but when I try to send a message back:

  1. I get forbidden request if I don't set any endpoint
  2. I get HTTPInternalServerError if I set to fixie http endpoint, but I'm not sure if this is correct. Really appreciate any help. Maybe @hirohisa can give some lights?
require 'line/bot'

class CallbacksController < ApplicationController
  def event_handler
    signature = request.env['HTTP_X_LINE_CHANNELSIGNATURE']
    unless client.validate_signature(request.body.read, signature)
      error 400 do 'Bad Request' end
    end

    receive_request = Line::Bot::Receive::Request.new(request.env)

    receive_request.data.each { |message|
      puts message.to_json
      case message.content

      when Line::Bot::Message::Text
         # All the code above works correctly this call is the problematic
         res = client.send_text(
          to_mid: message.from_mid,
          text: "Hola",
        )
        puts "#{res}"
        puts "#{client.endpoint}"
      end
    }

    render :nothing => true, status: :ok
  end

  def client
    client ||= Line::Bot::Client.new do |config|
      config.channel_id = ENV.fetch('LINE_CHANNEL_ID')
      config.channel_secret = ENV.fetch('LINE_CHANNEL_SECRET')
      config.channel_mid = ENV.fetch('LINE_CHANNEL_MID')
      # I get either 500 if set and forbidden if i remove this line
      config.endpoint = ENV.fetch('LINE_OUTBOUND_PROXY')
    end
  end
end

@caherrerapa
Copy link
Author

Closing as the request class doesn't support proxy. My bad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant