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

Twilio - failed to connect to room with error #304

Closed
JiyarMahmod opened this issue Sep 19, 2018 · 6 comments
Closed

Twilio - failed to connect to room with error #304

JiyarMahmod opened this issue Sep 19, 2018 · 6 comments
Assignees

Comments

@JiyarMahmod
Copy link

Description

hi iam pretty new to twilio and was interested in how it works so i downloaded the quickstart files from the github page and followed allong all the instructions and i have set up everything with the api keys and all and iam receving a token key in my app but when i press connect to join a room i get an error saying failed to connect to room with error and iam using the twilio console functions to generate the token with a simple code snippet.

This is the code i use to generate a token.

exports.handler = function(context, event, callback) {

const AccessToken = Twilio.jwt.AccessToken;
const VideoGrant = AccessToken.VideoGrant;

const token = new AccessToken(context.ACCOUNT_SID, context.API_KEY, context.API_SECRET, 3600);
token.identity = event.identity;

const videoGrant = new VideoGrant({room: '960710abcde'});

token.addGrant(videoGrant);

callback(null, {token: token.toJwt() });
};

this above code i use to get the token key to access the room thats named 960710abcde but still i get this error and i have printed the token inside xcode consol so iam getting the token... iam using xcode and the langugage is swift

the version of the twilio sdk is 2.4 so i guess it is the latest sence i installed it using cocoapods.

types of phones iam using is a iphone x and a iphone 7 and i have tryed it with the simulator sence i saw it was capable of that but that didnt work either i cannot even connect to the room with the first device. Even if i press connect at the same time on both phones it does not work

here is an image of the error i get:

img_1323

thanks in advance.

@ceaglest
Copy link
Contributor

ceaglest commented Sep 20, 2018

Hey @JiyarMahmod,

What kind of NSError is being returned in [room:didFailToConnectWithError:]? (Sorry that the QS does not do a good job of logging this) Can you send us debug logs of a connection attempt which show what the failure is?

TwilioVideo.setLogLevel(.debug)

These may also include a Call SID which we can use to take a look from the server perspective. I might have @ramapal help out with diagnosing this one as well.

Best,
Chris

@JiyarMahmod
Copy link
Author

JiyarMahmod commented Sep 20, 2018

Hi there @ceaglest!

Here is a log that is from start to end of the application. it says that i have a invalid access key but i do generate it from Twilio functions so iam not sure what it means. either way you may know the real reason behind this issue, take a look for yourself.

Thanks!

TwilioError.Logged.txt

@JiyarMahmod
Copy link
Author

Hi there @ceaglest!

i have fixed the issue now iam not sure why but the access key was invalid when i got it from twilios consol then i tried setting upp my own local server and that didnt work because the line was not secured with https then i just went to a hosting site and uploaded my tokengenerator.php file to hosting site among with the composer and autoload files then i just tryed it and it works perfect now. atleast i get connected now hahah. thanks for your time.

@JiyarMahmod
Copy link
Author

JiyarMahmod commented Sep 20, 2018

sence i got this working i just have one more quistion here. And iam just wondering how it is possible to automate things because now to join a room with two phones i have to go inside the tokengenerator.php file and set the identity manually and the room name to connect i tryed to add a second textfield and connected it to the tokenURL like this tokengenerator.php?identity=\(username)?roomName=\(roomName) but the room and name still stays the same it connects but it just says connected to room 960710abcde as (jiyar) even if i have changed my name to "bob" but i know the problem is in the .php file but is it possible to automate things and how? thanks @ceaglest

@ceaglest
Copy link
Contributor

ceaglest commented Sep 28, 2018

Hi @JiyarMahmod,

Sorry that I did not respond to your last question, did you get to the bottom of this? I usually use the python token server, but you should be able to set the identity and room name in server URL for all languages. If you're still having trouble I can take a look at the PHP server project when I get in tomorrow.

For python, and assuming localhost, I would mint a token with an identity "chris.ios" which is scoped to a room named "test".

http://127.0.0.1:5000/?identity=chris.ios&room=test

Best,
Chris

@ceaglest ceaglest self-assigned this Sep 28, 2018
@ceaglest
Copy link
Contributor

ceaglest commented Oct 11, 2018

Closing this one out since the original issue was resolved. Let us know if you still need help with the token server.

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

No branches or pull requests

2 participants