Home Stack Level Too Deep error using Twilio API
Reply: 0

Stack Level Too Deep error using Twilio API

anonn023432
1#
anonn023432 Published in 2018-02-02 20:58:08Z

So I'm trying to integrate the Twilio Programmable Video API with my Rails application and I created a separate controller for it as such:

require 'twilio-ruby'

class Api::V1::Coach::TwilioController < Api::V1::BaseController
  ACCOUNT_SID = ENV.fetch('TWILIO_ACCOUNT_SID')
  TWILIO_API_SID = ENV.fetch('TWILIO_KEY_SID')
  TWILIO_SECRET_KEY = ENV.fetch('TWILIO_SECRET_KEY')

  before_action :connect_to_twilio

  def create_room
    room = @twilio_token.video.rooms.create(
      unique_name: '12345',
      type: 'peer-to-peer',
      enable_turn: false
    ) 
    return render status:200, json: {     # This is the line indicated in the error
      success:true,
      jwt_token: @client,
      room_id: room.sid,
      room_status: room.status,
      room: room
    }
  end

   def connect_to_twilio
     @twilio_token = Twilio::REST::Client.new(TWILIO_API_SID, TWILIO_SECRET_KEY)
   end
end

But every time I make a request to the method I get an error:

SystemStackError (stack level too deep)

Which seems really weird because there is no recursive call here.

I believe that the error is because of the API request. But if I make the same request again then it throws a different error that room already exists. So the API request is successful, maybe there is something wrong with the render but can't really put my finger on it :/

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310516 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO