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

Cannot run samples with Video API Playground session & token #311

Closed
rafaelnobrekz opened this issue Apr 12, 2024 · 3 comments
Closed

Cannot run samples with Video API Playground session & token #311

rafaelnobrekz opened this issue Apr 12, 2024 · 3 comments

Comments

@rafaelnobrekz
Copy link

Hi! I'm trying out the SDK but am unable to run any of the samples.

  1. I created an Application with "Video" enabled
  2. I went into the Video API Playground, selected the account, app and relayed mode
  3. Injected the generated values into the fields for some of the samples (Basic, CallKit, Video-Transformers)

Result from the Console:

***** OpenTok iOS SDK | Version/Revision: ios-2.27.2/45959e736f520b422b614d9b93764af56554def9 | Library built on: Mar 15 2024 | CA bundle version: Mon Mar 11 15:25:27 2024 GMT | Copyright 2024 Vonage | https://www.vonage.com/legal/communications-apis/terms-of-use/
2024-04-11 12:03:29.303800-0300 Video-Transformers[11709:6967822] [Client] Updating selectors after delegate addition failed with: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service with pid 91 named com.apple.commcenter.coretelephony.xpc was invalidated from this process." UserInfo={NSDebugDescription=The connection to service with pid 91 named com.apple.commcenter.coretelephony.xpc was invalidated from this process.}
[ERROR] otk_anvil.cpp:452 - otk_anvil_on_session_info failed. nCode=1
[ERROR] rumor_client_v1.c:274 - otk_rumor_v1_client_send (pClient == NULL) rumor client is not initialized and cannot send message
session Failed to connect: Invalid token format

Additionally, I also tried creating sessions and tokens through the server API using python and ruby:

from opentok import Client, MediaModes
import time

api_key = "<api_key>" // Found in Settings, Master
api_secret = "<api_secret>" // Found in Settings, below the api_key

client = Client(api_key, api_secret)

session = client.create_session(media_mode=MediaModes.relayed)

print("session_id:")
print(session.session_id)
print("token:")
print(session.generate_token(expire_time=int(time.time()) + 10000))

Output:

Traceback (most recent call last):
  File "/Users/nobre/Downloads/vonage_token/lib/python3.12/site-packages/opentok/opentok.py", line 483, in create_session
    raise AuthError("Failed to create session, invalid credentials")
opentok.exceptions.AuthError: Failed to create session, invalid credentials

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/nobre/Downloads/vonage_token/generator.py", line 9, in <module>
    session = client.create_session(media_mode=MediaModes.relayed)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nobre/Downloads/vonage_token/lib/python3.12/site-packages/opentok/opentok.py", line 488, in create_session
    raise RequestError("Failed to create session: %s" % str(e))
opentok.exceptions.RequestError: Failed to create session: Failed to create session, invalid credentials

Ruby attempt:

require "opentok"

api_key = "<api_key>"
api_secret = "<api_secret>"

opentok = OpenTok::OpenTok.new api_key, api_secret

session = opentok.create_session

session_id = session.session_id

puts "session_id:"
puts session_id

token = session.generate_token({
    :role        => :moderator,
    :expire_time => Time.now.to_i+(7 * 24 * 60 * 60) # one week
});

puts "token:"
puts token

Output:

/Users/nobre/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/opentok-4.8.1/lib/opentok/client.rb:62:in `rescue in create_session': Failed to connect to OpenTok. Response code: Authentication failed while creating a session. API Key: <redacted> (OpenTok::OpenTokError)
	from /Users/nobre/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/opentok-4.8.1/lib/opentok/client.rb:47:in `create_session'
	from /Users/nobre/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/opentok-4.8.1/lib/opentok/opentok.rb:204:in `create_session'
	from generator.rb:8:in `<main>'
/Users/nobre/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/opentok-4.8.1/lib/opentok/client.rb:57:in `create_session': Authentication failed while creating a session. API Key: 12f24f75 (OpenTok::OpenTokAuthenticationError)
	from /Users/nobre/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/opentok-4.8.1/lib/opentok/opentok.rb:204:in `create_session'
	from generator.rb:8:in `<main>'

What am I doing wrong? Thank you.

@rafaelnobrekz
Copy link
Author

I've since realized with the hint from the Session inspector tool that the samples actually expect the ApplicationID when they mention API Key. That is very confusing! However, the backend session generation still doesn't work in any way I try it.

@v-kpheng
Copy link
Contributor

@rafaelnobrekz, likely your credentials were bad. They could've have been expired, for example.

Please try the following:

  • From Video API Playground, create a session and publish video from your browser.
  • From iOS Basic Video Chat, try to join that session and subscribe to the video that your browser is publishing.

The above should work.

@goncalocostamendes
Copy link
Contributor

@rafaelnobrekz I assume your issue was solved. If this is not the case please re-open the ticket

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

3 participants