Skip to content


Bug Fix for opentok Gem #3

merged 3 commits into from

2 participants


There is a bug in the gemfile, it can be replicated like this:

opentok =, API_SECRET)
session = opentok.create_session( '', {'p2p.preference' => 'enabled'})

The resulting session created is not p2p enabled in the production environment.

I went through the code and this issue is caused by the @api_url not being set by the location parameter passed into the create_session function.

Thanks Stijnster! Any comment is appreciated, this is my first pull request!

Song Zheng added some commits
Song Zheng content type 94be448
Song Zheng Revert "content type"
This reverts commit 94be448.
Song Zheng Bug fix: p2p sessions previously cannot be created because api_url wa…
…s not set in create_session function
@stijnster stijnster merged commit 4025e0f into stijnster:master

Hi Song,

I've merged it in and I'll create a new version and push that to rubygems.




Hi Song,

me again. Your modifications seem to brake the unit tests. The location parameter that you specify is not meant to provide the api_url. The api_url should be set with the creation of a new OpentTokSDK object like this;

opentok = @api_key, @api_secret, :api_url => ''

The location parameter that is specified in the create_session method is used to indicate where the requesting server is located (documentation in the sdk file describes it as; Generates a new OpenTok::Session and set it's session_id, situating it in TokBox's global network near the IP of the specified @location@.)

Can you retest, setting the api_url in the correct way and see if it works?

Just a tip; if you install "rspec" on your system, you can run the testsuite. Go to the folder where the source code is located and from there type "rspec" on the prompt.

Please let me know if I can be of any help!

Kind regards,



You are absolutely right. I had a wrong understanding and was chasing a non-existent bug. Sorry.


No problem!

Talk to you soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 18, 2012
  1. content type

    Song Zheng committed
Commits on Apr 23, 2012
  1. Revert "content type"

    Song Zheng committed
    This reverts commit 94be448.
  2. Bug fix: p2p sessions previously cannot be created because api_url wa…

    Song Zheng committed
    …s not set in create_session function
Showing with 3 additions and 0 deletions.
  1. +3 −0 lib/open_tok/open_tok_sdk.rb
3 lib/open_tok/open_tok_sdk.rb
@@ -122,6 +122,9 @@ def generate_token(opts = {})
# See for more information
def create_session(location='', opts={})
opts.merge!({:partner_id => @partner_id, :location=>location})
+ if location!=''
+ @api_url = location
+ end
doc = do_request("/session/create", opts)
if not doc.get_elements('Errors').empty?
raise doc.get_elements('Errors')[0].get_elements('error')[0].children.to_s
Something went wrong with that request. Please try again.