Comments (5)
here is my full code
`const createRoom = async (roomName, timeout) => {
try {
const svc = new RoomServiceClient(livekitHost, API, SECRET);
let rooms = await svc.listRooms();
for (let i = 0; i < rooms.length; i++) {
const room = rooms[i];
if (room.name === roomName) {
await svc.deleteRoom(roomName);
break;
}
}
const opts = {
name: roomName,
// timeout in seconds
emptyTimeout: 10 * 60,
maxParticipants: 2,
};
let createdRoom = await svc.createRoom(opts);
console.log(roomName, createdRoom);
return true;
} catch (error) {
console.log(error, "fn createRoom error");
}
return false;
};`
from node-sdks.
If you are running your application from within Docker, you'd need to pass LIVEKIT_API_KEY
and LIVEKIT_API_SECRET
environment vars to it. Otherwise your application will lack the proper credentials to make service requests.
from node-sdks.
hi @davidzhao , I already have declared LIVEKIT_API_KEY and LIVEKIT_API_SECRET in my env and inside container also the same env is reflecting.
My Senario is I have a expressjs rest api which has all my endpoints which serves to my react native app and i want a calling functionality. So i setup the free version. get the api and secret key and created a function name createRoom (above code) in my localmachine it creates a token and returns the list of rooms (let rooms = await svc.listRooms();) but when i create a docker container it fails to fetch list of rooms saying 401
from node-sdks.
let me share you sample app for testing
from node-sdks.
https://github.com/kmamtora/livekitstest
hi @davidzhao here is the code
I get this error from my server container
Error log
Error: Request failed with status code 401
at createError (/app/node_modules/livekit-server-sdk/node_modules/axios/lib/core/createError.js:16:15)
at settle (/app/node_modules/livekit-server-sdk/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/app/node_modules/livekit-server-sdk/node_modules/axios/lib/adapters/http.js:269:11)
at IncomingMessage.emit (node:events:524:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
config: {
url: '/twirp/livekit.RoomService/ListRooms',
method: 'post',
data: '{"names":[]}',
headers: {
Accept: 'application/json, text/plain, /',
'Content-Type': 'application/json',
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2aWRlbyI6eyJyb29tTGlzdCI6dHJ1ZX0sImlhdCI6MTY3NTM5OTA5MCwibmJmIjoxNjc1Mzk5MDkwLCJleHAiOjE2NzUzOTk2OTAsImlzcyI6IkFQSVdHOXIyNTNYRm1reiJ9.nPu1qwPY7XW2vor-pbC7RusYbvY4__rOkQ5RL63U9jM',
'User-Agent': 'axios/0.21.4',
'Content-Length': 12
},
baseURL: 'https://guruji.livekit.cloud/',
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
}
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype] {
abort: [Function (anonymous)],
aborted: [Function (anonymous)],
connect: [Function (anonymous)],
error: [Function (anonymous)],
socket: [Function (anonymous)],
timeout: [Function (anonymous)],
finish: [Function: requestOnFinish]
},
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: 12,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: true,
socket: TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
secureConnecting: false,
_SNICallback: null,
servername: 'guruji.livekit.cloud',
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object: null prototype],
_eventsCount: 9,
connecting: false,
_hadError: false,
_parent: null,
_host: 'guruji.livekit.cloud',
_closeAfterHandlingError: false,
_readableState: [ReadableState],
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: false,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: [TLSWrap],
_requestCert: true,
_rejectUnauthorized: true,
timeout: 5000,
parser: null,
_httpMessage: null,
[Symbol(res)]: [TLSWrap],
[Symbol(verified)]: true,
[Symbol(pendingSession)]: null,
[Symbol(async_id_symbol)]: -1,
[Symbol(kHandle)]: [TLSWrap],
[Symbol(lastWriteQueueSize)]: 0,
[Symbol(timeout)]: Timeout {
_idleTimeout: 5000,
_idlePrev: [TimersList],
_idleNext: [TimersList],
_idleStart: 49413,
_onTimeout: [Function: bound ],
_timerArgs: undefined,
_repeat: null,
_destroyed: false,
[Symbol(refed)]: false,
[Symbol(kHasPrimitive)]: false,
[Symbol(asyncId)]: 568,
[Symbol(triggerId)]: 566
},
[Symbol(kBuffer)]: null,
[Symbol(kBufferCb)]: null,
[Symbol(kBufferGen)]: null,
[Symbol(kCapture)]: false,
[Symbol(kSetNoDelay)]: false,
[Symbol(kSetKeepAlive)]: true,
[Symbol(kSetKeepAliveInitialDelay)]: 1,
[Symbol(kBytesRead)]: 0,
[Symbol(kBytesWritten)]: 0,
[Symbol(connect-options)]: [Object]
},
_header: 'POST /twirp/livekit.RoomService/ListRooms HTTP/1.1\r\n' +
'Accept: application/json, text/plain, /\r\n' +
'Content-Type: application/json\r\n' +
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2aWRlbyI6eyJyb29tTGlzdCI6dHJ1ZX0sImlhdCI6MTY3NTM5OTA5MCwibmJmIjoxNjc1Mzk5MDkwLCJleHAiOjE2NzUzOTk2OTAsImlzcyI6IkFQSVdHOXIyNTNYRm1reiJ9.nPu1qwPY7XW2vor-pbC7RusYbvY4__rOkQ5RL63U9jM\r\n' +
'User-Agent: axios/0.21.4\r\n' +
'Content-Length: 12\r\n' +
'Host: guruji.livekit.cloud\r\n' +
'Connection: keep-alive\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object: null prototype],
requests: [Object: null prototype] {},
sockets: [Object: null prototype] {},
freeSockets: [Object: null prototype],
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 1,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/twirp/livekit.RoomService/ListRooms',
_ended: true,
res: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 3,
_maxListeners: undefined,
socket: null,
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
rawHeaders: [Array],
rawTrailers: [],
joinDuplicateHeaders: undefined,
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 401,
statusMessage: 'Unauthorized',
client: [TLSSocket],
_consuming: false,
_dumped: false,
req: [Circular *1],
responseUrl: 'https://guruji.livekit.cloud/twirp/livekit.RoomService/ListRooms',
redirects: [],
[Symbol(kCapture)]: false,
[Symbol(kHeaders)]: [Object],
[Symbol(kHeadersCount)]: 8,
[Symbol(kTrailers)]: null,
[Symbol(kTrailersCount)]: 0
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'guruji.livekit.cloud',
protocol: 'https:',
_redirectable: Writable {
_writableState: [WritableState],
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_options: [Object],
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 12,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: [Circular *1],
_currentUrl: 'https://guruji.livekit.cloud/twirp/livekit.RoomService/ListRooms',
[Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kEndCalled)]: true,
[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]
},
[Symbol(errored)]: null,
[Symbol(kUniqueHeaders)]: null
},
response: {
status: 401,
statusText: 'Unauthorized',
headers: {
'content-length': '305',
'content-type': 'text/plain; charset=utf-8',
date: 'Fri, 03 Feb 2023 04:36:45 GMT',
vary: 'Origin'
},
config: {
url: '/twirp/livekit.RoomService/ListRooms',
method: 'post',
data: '{"names":[]}',
headers: [Object],
baseURL: 'https://guruji.livekit.cloud/',
transformRequest: [Array],
transformResponse: [Array],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
transitional: [Object]
},
request: <ref *1> ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: 12,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: true,
socket: [TLSSocket],
_header: 'POST /twirp/livekit.RoomService/ListRooms HTTP/1.1\r\n' +
'Accept: application/json, text/plain, /\r\n' +
'Content-Type: application/json\r\n' +
'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2aWRlbyI6eyJyb29tTGlzdCI6dHJ1ZX0sImlhdCI6MTY3NTM5OTA5MCwibmJmIjoxNjc1Mzk5MDkwLCJleHAiOjE2NzUzOTk2OTAsImlzcyI6IkFQSVdHOXIyNTNYRm1reiJ9.nPu1qwPY7XW2vor-pbC7RusYbvY4__rOkQ5RL63U9jM\r\n' +
'User-Agent: axios/0.21.4\r\n' +
'Content-Length: 12\r\n' +
'Host: guruji.livekit.cloud\r\n' +
'Connection: keep-alive\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [Agent],
socketPath: undefined,
method: 'POST',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/twirp/livekit.RoomService/ListRooms',
_ended: true,
res: [IncomingMessage],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'guruji.livekit.cloud',
protocol: 'https:',
_redirectable: [Writable],
[Symbol(kCapture)]: false,
[Symbol(kBytesWritten)]: 0,
[Symbol(kEndCalled)]: true,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(errored)]: null,
[Symbol(kUniqueHeaders)]: null
},
data: 'invalid token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2aWRlbyI6eyJyb29tTGlzdCI6dHJ1ZX0sImlhdCI6MTY3NTM5OTA5MCwibmJmIjoxNjc1Mzk5MDkwLCJleHAiOjE2NzUzOTk2OTAsImlzcyI6IkFQSVdHOXIyNTNYRm1reiJ9.nPu1qwPY7XW2vor-pbC7RusYbvY4__rOkQ5RL63U9jM, error: square/go-jose/jwt: validation failed, token not valid yet (nbf)'
},
isAxiosError: true,
toJSON: [Function: toJSON]
}
If I copy the same token (from above error) and create a curl command and execute inside the same container it gives positive response as aspected.
I observed 1 more thing when i create a container in my local machine I get positive response
from node-sdks.
Related Issues (20)
- EgressClient failed to export stream. HOT 1
- Text Chat via WebRTC Data Channel is unusable HOT 3
- Join room using the sdk from server HOT 1
- AccessToken.addGrant() should not replace previous grants HOT 1
- Cloudflare Worker support - avoid using 'crypto' from Node HOT 1
- updateParticipant throws uncatchable 500 error
- Documentation Update: `emptyTimeout` in `CreateOptions`
- key "name" missing in WebhookEvent type HOT 1
- After upgrading to v2, all functions like `createIngress()` are broken
- Import error in nestjs typescript HOT 7
- sendData is not working HOT 1
- Migration Doc: In `listRooms` response, field `creationTime` has been changed from Int to BigInt HOT 1
- Dependency Dashboard
- Livekit importing err when working with nestjs. HOT 1
- Dependency issue livekit-server-sdk HOT 1
- Issue with Parallel Room Instances and Audio Publishing HOT 2
- IO error: invalid peer certificate: UnknownIssuer HOT 2
- Inquiry about compatibility of Live Kit SDK with Deno HOT 4
- Expose WebhookEvent type HOT 1
- Cannot find module 'long' HOT 4
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 node-sdks.