Description
I want to preface this with I saw this was posted and there was a fix put in for it #783 , however I am still seeing the problem.
This is the exact issue pasted from the Heroku logs, with the keys and userId's in the parameters modified for obvious reasons:
2016-03-07T23:12:44.841892+00:00 app[web.1]: OpenTok: Error while creating session
2016-03-07T23:12:44.841904+00:00 app[web.1]: Request failed with response code undefined
2016-03-07T23:12:44.841905+00:00 app[web.1]: Raw response:
2016-03-07T23:12:44.841906+00:00 app[web.1]: undefined
2016-03-07T23:12:44.841906+00:00 app[web.1]:
2016-03-07T23:12:44.843620+00:00 app[web.1]: OpenTok: Sent the following request:
2016-03-07T23:12:44.843634+00:00 app[web.1]: {"url":"https://api.opentok.com/hl/session/create","method":"POST","headers":{"X-TB-PARTNER-AUTH":"key:secret"},"body":{"userIdForConnection":"xxx","userId":"yyy","location_hint":"localhost"},"followRedirect":false}
2016-03-07T23:12:44.843636+00:00 app[web.1]:
2016-03-07T23:12:44.861257+00:00 app[web.1]: /app/node_modules/parse-server/lib/index.js:288
2016-03-07T23:12:44.873516+00:00 app[web.1]: throw err;
2016-03-07T23:12:44.873578+00:00 app[web.1]:
2016-03-07T23:12:44.873592+00:00 app[web.1]: TypeError: first argument must be a string or Buffer
2016-03-07T23:12:44.873594+00:00 app[web.1]: at ClientRequest.OutgoingMessage.write (_http_outgoing.js:443:11)
2016-03-07T23:12:44.873595+00:00 app[web.1]: at Request.write (/app/node_modules/request/request.js:1371:25)
2016-03-07T23:12:44.873595+00:00 app[web.1]: at end (/app/node_modules/request/request.js:561:16)
2016-03-07T23:12:44.873608+00:00 app[web.1]: at processImmediate [as _immediateCallback] (timers.js:383:17)
2016-03-07T23:12:44.914729+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-03-07T23:12:44.914981+00:00 app[web.1]: npm ERR! node v5.7.1
2016-03-07T23:12:44.916121+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-03-07T23:12:44.917253+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the parse-server-example package,
2016-03-07T23:12:44.917446+00:00 app[web.1]: npm ERR! not with npm itself.
2016-03-07T23:12:44.917633+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-03-07T23:12:44.917998+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-03-07T23:12:44.929197+00:00 app[web.1]:
2016-03-07T23:12:44.929651+00:00 app[web.1]: npm ERR! /app/npm-debug.log
As with the other issue, this is the call from opentok.js that is making the call
OpenTokSDK.prototype.apiRequest = function(endpoint, authScheme, options, cb) {
// options is optional
if (cb === undefined) { cb = options; options = {}; }
var requestOptions = {
url: urlFromEndpoint(endpoint, options.endpoint),
method: methodFromEndpoint(endpoint),
headers: {},
body: options.data || {},
success: function(response) {
cb(null, response);
},
error: function(response) {
cb(new Error("Request failed with response code " + response.status + "\n" +
"Raw response: \n" + response.text + "\n"));
}
};
if (authScheme === AUTH.PARTNER) {
requestOptions.headers[authScheme] = this.apiKey + ':' + this.apiSecret;
} else if (authScheme === AUTH.TOKEN) {
requestOptions.headers[authScheme] = this.generateToken.apply( this, options.auth );
} else {
console.warn("OpenTok: No known authentication scheme chosen for the following request: \n" +
JSON.stringify(requestOptions) + "\n");
}
Parse.Cloud.httpRequest(requestOptions);
console.log("OpenTok: Sent the following request: \n" + JSON.stringify(requestOptions) + "\n");
return;
};
I have narrowed it down to that Parse.cloud.httpRequest(requestOptions) that is causing this issue.
You can also see what the actual request was being made in the Heroku logs. I also want to mention that when I hit that endpoint in CURL with the actual key:secret, it actually comes back with a 200 and no errors. So I am not sure why this is even erroring in the first place.
I also have updated my parse-server on Heroku with the latest code as of 30 minutes ago, so it has the code that fixed #783 in there, and I've verified it by looking at the file on my Heroku server.
Any ideas? Is this an issue with the 'request node' module that is required inside of the httpRequest.js?