# Strange response from openvidu-node-client library

**URL:** <https://openvidu.discourse.group/t/strange-response-from-openvidu-node-client-library/391>\
**Category:** Issues developing apps\
**Tags:** v2\
**Created:** [April 3, 2020, 10:52am UTC](https://openvidu.discourse.group/t/strange-response-from-openvidu-node-client-library/391 "2020-04-03T10:52:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mirko\_Bertone](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/mirko_bertone/32/216_2.png) [@Mirko\_Bertone](https://openvidu.discourse.group/u/Mirko_Bertone)\
**Post date:** [April 3, 2020, 10:52am UTC](https://openvidu.discourse.group/t/strange-response-from-openvidu-node-client-library/391/1 "2020-04-03T10:52:54Z")

</div>

Hello!  
When I use my route I receive an error from createSession() and I don’t know why.  
**My route:**  
router.post(’/video/session’, (req, res) =\> {

var openVidu = new OpenVidu(‘[https://192.168.1.118:4443](https://192.168.1.118:4443)’, ‘pippo’);

var tokenOptions = {  
data: ‘serverData’,  
role: OpenViduRole.PUBLISHER  
};

console.log(‘START’);

openVidu  
.createSession({})  
.then(session =\> {  
session  
.generateToken(tokenOptions)  
.then(token =\> {  
return res  
.status(200)  
.json({ data: token, message: ‘generateToken’ });  
})  
.catch(error =\> {  
return res.status(500).json({ data: error, message: ‘tokenError’ });  
});  
})  
.catch(error =\> {  
return res.status(500).json({ data: error, message: ‘sessionError’ });  
});  
});

**The response:**  
Server running…  
DB Connected!  
START  
Writable {  
\_writableState: WritableState {  
objectMode: false,  
highWaterMark: 16384,  
finalCalled: false,  
needDrain: false,  
ending: false,  
ended: false,  
finished: false,  
destroyed: false,  
decodeStrings: true,  
defaultEncoding: ‘utf8’,  
length: 0,  
writing: false,  
corked: 0,  
sync: true,  
bufferProcessing: false,  
onwrite: [Function: bound onwrite],  
writecb: null,  
writelen: 0,  
afterWriteTickInfo: null,  
bufferedRequest: null,  
lastBufferedRequest: null,  
pendingcb: 0,  
prefinished: false,  
errorEmitted: false,  
emitClose: true,  
autoDestroy: false,  
bufferedRequestCount: 0,  
corkedRequestsFree: {  
next: null,  
entry: null,  
finish: [Function: bound onCorkedFinish]  
}  
},  
writable: true,  
\_events: [Object: null prototype] {  
response: [Function: handleResponse],  
error: [Function: handleRequestError]  
},  
\_eventsCount: 2,  
\_maxListeners: undefined,  
\_options: {  
protocol: ‘https:’,  
maxRedirects: 21,  
maxBodyLength: 10485760,  
path: ‘/api/sessions’,  
method: ‘POST’,  
headers: {  
Accept: ‘application/json, text/plain, _/_’,  
‘Content-Type’: ‘application/json’,  
Authorization: ‘Basic T1BFTlZJRFVBUFA6cGlwcG8=’,  
‘User-Agent’: ‘axios/0.19.0’,  
‘Content-Length’: 160  
},  
agent: undefined,  
auth: undefined,  
hostname: ‘192.168.1.118’,  
port: ‘4443’,  
nativeProtocols: { ‘http:’: [Object], ‘https:’: [Object] },  
pathname: ‘/api/sessions’  
},  
\_redirectCount: 0,  
\_redirects: [],  
\_requestBodyLength: 160,  
\_requestBodyBuffers: [  
{  
data: \<Buffer 7b 22 6d 65 64 69 61 4d 6f 64 65 22 3a 22 52 4f 55 54 45 44 22 2c 22 72 65 63 6f 72 64 69 6e 67 4d 6f 64 65 22 3a 22 4d 41 4e 55 41 4c 22 2c 22 64 65 … 110 more bytes\>,  
encoding: undefined  
}  
],  
\_onNativeResponse: [Function],  
\_currentRequest: ClientRequest {  
\_events: [Object: null prototype] {  
response: [Function],  
socket: [Function],  
abort: [Function],  
aborted: [Function],  
error: [Function],  
timeout: [Function]  
},  
\_eventsCount: 6,  
\_maxListeners: undefined,  
outputData: [],  
outputSize: 0,  
writable: true,  
\_last: true,  
chunkedEncoding: false,  
shouldKeepAlive: false,  
useChunkedEncodingByDefault: true,  
sendDate: false,  
\_removedConnection: false,  
\_removedContLen: false,  
\_removedTE: false,  
\_contentLength: null,  
\_hasBody: true,  
\_trailer: ‘’,  
finished: false,  
\_headerSent: true,  
socket: TLSSocket {  
\_tlsOptions: [Object],  
\_secureEstablished: true,  
\_securePending: false,  
\_newSessionPending: false,  
\_controlReleased: true,  
\_SNICallback: null,  
servername: false,  
alpnProtocol: false,  
authorized: false,  
authorizationError: ‘DEPTH\_ZERO\_SELF\_SIGNED\_CERT’,  
encrypted: true,  
\_events: [Object: null prototype],  
\_eventsCount: 9,  
connecting: false,  
\_hadError: true,  
\_parent: null,  
\_host: null,  
\_readableState: [ReadableState],  
readable: false,  
\_maxListeners: undefined,  
\_writableState: [WritableState],  
writable: false,  
allowHalfOpen: false,  
\_sockname: null,  
\_pendingData: null,  
\_pendingEncoding: ‘’,  
server: undefined,  
\_server: null,  
ssl: null,  
\_requestCert: true,  
\_rejectUnauthorized: true,  
parser: null,  
\_httpMessage: [Circular],  
[Symbol(res)]: [TLSWrap],  
[Symbol(asyncId)]: 46,  
[Symbol(kHandle)]: null,  
[Symbol(lastWriteQueueSize)]: 405,  
[Symbol(timeout)]: null,  
[Symbol(kBuffer)]: null,  
[Symbol(kBufferCb)]: null,  
[Symbol(kBufferGen)]: null,  
[Symbol(kCapture)]: false,  
[Symbol(kBytesRead)]: 0,  
[Symbol(kBytesWritten)]: 405,  
[Symbol(connect-options)]: [Object]  
},  
connection: TLSSocket {  
\_tlsOptions: [Object],  
\_secureEstablished: true,  
\_securePending: false,  
\_newSessionPending: false,  
\_controlReleased: true,  
\_SNICallback: null,  
servername: false,  
alpnProtocol: false,  
authorized: false,  
authorizationError: ‘DEPTH\_ZERO\_SELF\_SIGNED\_CERT’,  
encrypted: true,  
\_events: [Object: null prototype],  
\_eventsCount: 9,  
connecting: false,  
\_hadError: true,  
\_parent: null,  
\_host: null,  
\_readableState: [ReadableState],  
readable: false,  
\_maxListeners: undefined,  
\_writableState: [WritableState],  
writable: false,  
allowHalfOpen: false,  
\_sockname: null,  
\_pendingData: null,  
\_pendingEncoding: ‘’,  
server: undefined,  
\_server: null,  
ssl: null,  
\_requestCert: true,  
\_rejectUnauthorized: true,  
parser: null,  
\_httpMessage: [Circular],  
[Symbol(res)]: [TLSWrap],  
[Symbol(asyncId)]: 46,  
[Symbol(kHandle)]: null,  
[Symbol(lastWriteQueueSize)]: 405,  
[Symbol(timeout)]: null,  
[Symbol(kBuffer)]: null,  
[Symbol(kBufferCb)]: null,  
[Symbol(kBufferGen)]: null,  
[Symbol(kCapture)]: false,  
[Symbol(kBytesRead)]: 0,  
[Symbol(kBytesWritten)]: 405,  
[Symbol(connect-options)]: [Object]  
},  
\_header: ‘POST /api/sessions HTTP/1.1\r\n’ +  
‘Accept: application/json, text/plain, _/_\r\n’ +  
‘Content-Type: application/json\r\n’ +  
‘Authorization: Basic T1BFTlZJRFVBUFA6cGlwcG8=\r\n’ +  
‘User-Agent: axios/0.19.0\r\n’ +  
‘Content-Length: 160\r\n’ +  
‘Host: 192.168.1.118:4443\r\n’ +  
‘Connection: close\r\n’ +  
‘\r\n’,  
\_onPendingData: [Function: noopPendingOutput],  
agent: Agent {  
\_events: [Object: null prototype],  
\_eventsCount: 2,  
\_maxListeners: undefined,  
defaultPort: 443,  
protocol: ‘https:’,  
options: [Object],  
requests: {},  
sockets: [Object],  
freeSockets: {},  
keepAliveMsecs: 1000,  
keepAlive: false,  
maxSockets: Infinity,  
maxFreeSockets: 256,  
maxCachedSessions: 100,  
\_sessionCache: [Object],  
[Symbol(kCapture)]: false  
},  
socketPath: undefined,  
method: ‘POST’,  
insecureHTTPParser: undefined,  
path: ‘/api/sessions’,  
\_ended: false,  
res: null,  
aborted: false,  
timeoutCb: null,  
upgradeOrConnect: false,  
parser: null,  
maxHeadersCount: null,  
reusedSocket: false,  
\_redirectable: [Circular],  
[Symbol(kCapture)]: false,  
[Symbol(kNeedDrain)]: false,  
[Symbol(corked)]: 0,  
[Symbol(kOutHeaders)]: [Object: null prototype] {  
accept: [Array],  
‘content-type’: [Array],  
authorization: [Array],  
‘user-agent’: [Array],  
‘content-length’: [Array],  
host: [Array]  
}  
},  
\_currentUrl: ‘[https://192.168.1.118:4443/api/sessions](https://192.168.1.118:4443/api/sessions)’,  
[Symbol(kCapture)]: false  
}

Can someone understand if I’m making mistakes? Thanks!

---

<div class="post-metadata">

**Author:** ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)\
**Post date:** [April 5, 2020, 1:58pm UTC](https://openvidu.discourse.group/t/strange-response-from-openvidu-node-client-library/391/2 "2020-04-05T13:58:09Z")

</div>

It is hard to follow the log.

Can you please add more console.log(‘xxxx’) sentences in response and error handlers to understand what code is being executed and param values?

---

<div class="post-metadata">

**Author:** ![Deepinder\_Singh](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/deepinder_singh/32/221_2.png) [@Deepinder\_Singh](https://openvidu.discourse.group/u/Deepinder_Singh)\
**Post date:** [April 5, 2020, 8:22pm UTC](https://openvidu.discourse.group/t/strange-response-from-openvidu-node-client-library/391/3 "2020-04-05T20:22:24Z")

</div>

facing same error, after cloning and running locally js-node repo, whenever a request for get-token goes this error is printed on the console.  
I managed to find out the reason as the hostname and port supplied by session in generate token is empty, if I hardcode it in node modules Session.js, it works, but is it empty when the constructor is called with proper URLS?

---

<div class="post-metadata">

**Author:** ![Mirko\_Bertone](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/mirko_bertone/32/216_2.png) [@Mirko\_Bertone](https://openvidu.discourse.group/u/Mirko_Bertone)\
**Post date:** [April 5, 2020, 9:14pm UTC](https://openvidu.discourse.group/t/strange-response-from-openvidu-node-client-library/391/4 "2020-04-05T21:14:00Z")

</div>

I discover what is it! It given by TLS validation. I added in my server: process.env.NODE\_TLS\_REJECT\_UNAUTHORIZED = “0”;

---

<div class="post-metadata">

**Author:** ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)\
**Post date:** [April 5, 2020, 11:47pm UTC](https://openvidu.discourse.group/t/strange-response-from-openvidu-node-client-library/391/5 "2020-04-05T23:47:09Z")

</div>

Good to know! Thank for reporting.
