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’, ‘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’,
[Symbol(kCapture)]: false
}
Can someone understand if I’m making mistakes? Thanks!