OpenTok-Ruby-SDK
OpenTok-Ruby-SDK copied to clipboard
OpenTok authenticaion failed on production
OpenTok is working fine locally, but when I tried on production, I got this error "Failed to connect to OpenTok. Response code: Authentication failed while creating a session. API Key: 46720112" I don't understand what's going on because everything is working fine locally, so I'm 100% sure there's an edge case somewhere.
Ruby version: 2.6.3 Rails version: 5.0 OpenTok version: 4.0.0
Hi @ahmadabdelhalim,
Could you share some of your Ruby code for generating the session? Have you tried inspecting what is returned from that code to see what the session value consists of? Have you done that both locally and in production? Are you passing your API credentials in the production instance?
Hi @benhayehudi I did inspect the code and the opentok instance is working correctly, the problem appears when I try to generate a session ( and yes the API credentials are working fine ) After further investigating I noticed that the timezone might be a problem? not sure what's the connection between the timezone and opentok, but I'm using docker on production, so I'm not sure if that's the issue. This is the code I use for creating the session. It's working fine locally.
before_action :configure_opentok
def index
session = @opentok.create_session(:media_mode => :routed)
session_id = session.session_id
render json: {
session_id: session_id
}
end
private
def configure_opentok
@opentok ||= OpenTok::OpenTok.new(ENV['OPENTOK_API_KEY'], ENV['OPENTOK_API_SECRET'])
end
Hi @ahmadabdelhalim, Your code looks correct to me. There might be something going on besides the code, so I'm going to tag my colleague @MichaelJolley who might have some insight.
I don't know Ruby well at all, but in the Ruby SDK we generate a JWT when we send requests to the REST API. @benhayehudi, with this running in a container, could we be using a time that is out of sync or expired?
@ahmadabdelhalim can you confirm that the system time of the containers host machine is correct?
That's the only thing I see as it relates to time.