Comments (5)
So I wrote this to test the session id as generated via the REST api and fixed my problem:
var http = require('https');
var qs = require('qs');
var xmljson = require('xmljson').to_json;
function invoke(url, params, callback)
{
try
{
var postData = qs.stringify(params || {});
var options = {
host: 'api.opentok.com',
path: url,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': postData.length,
'X-TB-PARTNER-AUTH' : global.config.opentok.key+':'+global.config.opentok.secret,
},
};
var req = http.request(options, function(res){
var str = "";
res.setEncoding('utf8');
res.on('data', function (chunk) { str += chunk; });
res.on('end', function () {
xmljson(str,callback);
});
});
req.on('error',function(e){
if (callback) callback(e);
});
req.write(postData);
req.end();
}
catch (ex)
{
if (callback) callback(ex);
}
}
exports.createSession = function(callback)
{
invoke('/hl/session/create',{ 'p2p.preference' : 'disabled' },function(err,data){
if (err || !data)
{
callback(err || "Unable to issue session id");
}
else
{
callback(false,data.sessions.Session.session_id);
}
});
};
from opentok-node.
@EvilTrev that's interesting... Can you give me a Session ID that was generated from the SDK (not your REST experiment) so I can take a look at why it might not be routed?
from opentok-node.
I've worked out what is going on... so I put this code back in place:
exports.createSession = function(callback)
{
console.log("Options :",global.config.opentok.options);
opentok.createSession(global.config.opentok.options, function(err,session){
if (err || !session)
{
if (callback) callback(err || "No session");
}
else
{
console.log("SessionId :",session.sessionId);
if (callback) callback(err,session.sessionId);
}
});
}
And here is the output from a couple of attempts:
Options : { mediaMode: 'routed' }
SessionId : 1_MX4zMzQ1NzkzMn5-MTQyMTg3ODcwODkzMH44VTB3ZVNqZ3gwQW5HanBCUVM3M29hamZ-fg
Options : { 'p2p.preference': 'disabled' }
SessionId : 2_MX4zMzQ1NzkzMn5-MTQyMTg3ODgwMTUyM34wSy84eExxRHRzYmpDVm42N2R5N1JQZ0Z-UH4
It looks like my shared and static config object being passed in is modified by the function used to create session keys. The first attempt works, the following attempts do not (due to alterations).
from opentok-node.
@EvilTrev wow that's a tricky one, but good catch.
It looks like the implementation actually does copy the options as backupOpts
because we intended not to alter that object, but then we ignored that and altered it anyway. Should be a straight forward fix. Would accept PR :)
from opentok-node.
I'm just glad to help out!
from opentok-node.
Related Issues (20)
- OpenTok startArchive/stopArchive on the FE side HOT 1
- Error: The token does not match the session ID. reporting randomly HOT 1
- Does not support IPv6
- OT_XDOMAIN_OR_PARSING_ERROR HOT 1
- streamMode is missing in archive options HOT 2
- Patch Archive checks for wrong http response code
- body-parser-1.12.4.tgz: 5 vulnerabilities (highest severity is: 7.5) reachable - autoclosed HOT 1
- express-3.21.2.tgz: 13 vulnerabilities (highest severity is: 9.8) reachable
- ejs-2.7.4.tgz: 3 vulnerabilities (highest severity is: 9.8) unreachable
- request-2.88.2.tgz: 2 vulnerabilities (highest severity is: 9.8) unreachable HOT 3
- express-4.12.4.tgz: 4 vulnerabilities (highest severity is: 7.5) unreachable
- Option to mute microphone of the publisher through a button HOT 1
- bug: error 400 (bad request) using NodeJS SDK method `unregisterCallback` HOT 1
- jsonwebtoken-8.2.0.tgz: 4 vulnerabilities (highest severity is: 9.8) - autoclosed HOT 1
- opentok-2.15.1.tgz: 3 vulnerabilities (highest severity is: 8.1) - autoclosed HOT 1
- Problem with initializing OpenTok HOT 1
- Unable to set the archiving resolution when using automatic session archive
- 2.17.0 breaks due to SyntaxError, automatic json parsing in needle HOT 2
- Session not found error when manual archive startArchive right after createSession with valid session id. HOT 1
- listStreams: TypeError: Cannot read properties of undefined (reading 'map') HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opentok-node.