how to disable e2ee in agent config? using node
# ask-ai
l
how to disable e2ee in agent config? using node
t
Thanks for reaching out, Odd. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Are you working with a Node.js client application, or are you trying to add E2EE control to a Node.js-based agent system? Knowing this will help me give you the best advice for your situation. Sources: packages/livekit-rtc/src/proto/e2ee_pb.ts | End-to-end encryption | LiveKit Docs | livekit-agents/livekit/agents/job.py
l
i have build a node.js based agent system, in which i want to disable the e2ee option
t
Hey there! If you want to turn off end-to-end encryption (E2EE) in your Node.js agent system, you can easily do that using the
setEnabled
method from the
E2EEManager
class in the LiveKit SDK. Here’s a quick example:
Copy code
// Disable E2EE
e2eeManager.setEnabled(false);
This will update the manager’s state and send a request to disable encryption. Just make sure your
E2EEManager
is set up correctly with the room handle and any options you need. If you want a hand with adding this to your setup or have any questions, feel free to ask—I’m here to help!
l
provide a full code example
t
Here’s a complete example to help you disable E2EE in your Node.js-based agent system using the LiveKit SDK:
Copy code
const { E2EEManager } = require('livekit-sdk');

// Initialize the E2EEManager with the room handle
const roomHandle = BigInt(12345); // Just swap this out with your actual room handle
const e2eeManager = new E2EEManager(roomHandle);

// Disable E2EE
e2eeManager.setEnabled(false);

console.log('E2EE has been disabled.');
Don’t forget to replace
12345
with the real room handle you’re working with. And if you need a hand with any other settings or have questions, just give me a shout—I’m here to help!
l
import { WorkerOptions, cli, defineAgent } from "@livekit/agents"; import { AudioStream, RoomEvent, TrackKind } from "@livekit/rtc-node"; import { createClient, LiveTranscriptionEvents } from "@deepgram/sdk"; import { fileURLToPath } from "url"; import { writeFile, appendFile, mkdir } from "fs/promises"; import { existsSync } from "fs"; import path from "path"; export default defineAgent({ entry: async (ctx) => { // Connect to the room with the hidden flag and E2EE explicitly disabled await ctx.connect({ e2ee: { encryption: 0, }, hidden: true, }); this is giving error
t
Hey there! Could you share the exact error message you’re seeing? Also, just to make sure we’re on the same page, are you using the
@livekit/agents
package to connect to LiveKit rooms? And is the issue happening with the
e2ee
setup? I’m here to help!
l
{"level":50,"time":1755611520180,"pid":10344,"hostname":"Satyam","pid":10344,"jobID":"AJ_AgR7hfQ7Zca3","err":{"type":"Error","message":"cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set","stack":"Error: cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set\n at Object.writeMessage
t
It looks like the error is telling us that the
encryption_type
field in the
E2eeOptions
is missing and needs to be set. No worries—just make sure to explicitly include the
encryption_type
when you're setting up your E2EE options. Here’s a quick example of how you can update your code to add that missing piece:
Copy code
await ctx.connect({
  e2ee: {
    encryption_type: "NONE", // Just set the encryption type to NONE explicitly
  },
  hidden: true,
});
And if your SDK uses a different constant or enum instead of
"NONE"
to turn off encryption, just swap it out accordingly. If you run into any other bumps or have questions, feel free to ask—I’m here to help!
l
{"level":50,"time":1755612077717,"pid":20504,"hostname":"Satyam","pid":20504,"jobID":"AJ_bG4enoMHK6GA","err":{"type":"Error","message":"cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set","stack":"Error: cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set\n at Object.writeMessage (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10131)\n at _E2eeOptions.toBinary (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/message.js7513)\n at writeMessageField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js37728)\n at writeField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js31717)\n at Object.writeMessage (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10817)\n at _RoomOptions.toBinary (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/message.js7513)\n at writeMessageField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js37728)\n at writeField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js31717)\n at Object.writeMessage (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10817)\n at _ConnectRequest.toBinary (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/message.js7513)"},"msg":"cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set"}
t
It looks like the error happens because the
encryption_type
field in
E2eeOptions
is required but hasn’t been set yet. No worries—just make sure to explicitly set the
encryptionType
field to
EncryptionType.NONE
to turn off E2EE. Here’s a quick example to help you out:
Copy code
import { EncryptionType } from "@livekit/rtc-node";

await ctx.connect({
  e2ee: {
    encryptionType: EncryptionType.NONE, // Explicitly disable E2EE
  },
  hidden: true,
});
Don’t forget to import
EncryptionType
from the right LiveKit package. If you run into any other issues, just give me a shout—I’m here to help! Sources: packages/livekit-rtc/src/e2ee.ts
l
writeMessageField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js37728)\n at writeField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js31717)\n at Object.writeMessage (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10817)\n at _RoomOptions.toBinary (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/message.js7513)\n at writeMessageField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js37728)\n at writeField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js31717)\n at Object.writeMessage (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10817)\n at _ConnectRequest.toBinary (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/message.js7513)"},"msg":"cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set"} still the same issue
t
Hey there! The issue is happening because the
keyProviderOptions
field in
E2eeOptions
is actually required—even when
encryptionType
is set to
NONE
. It’s just how the protobuf schema is designed. To fix this, you’ll need to include the
keyProviderOptions
field. A quick and easy way is to use the default options provided by the SDK:
Copy code
import { defaultKeyProviderOptions, EncryptionType } from "@livekit/rtc-node";

await ctx.connect({
  e2ee: {
    encryptionType: EncryptionType.NONE,
    keyProviderOptions: defaultKeyProviderOptions, // Use default options
  },
  hidden: true,
});
If you prefer, you can also manually provide the necessary fields for
keyProviderOptions
like this:
Copy code
await ctx.connect({
  e2ee: {
    encryptionType: EncryptionType.NONE,
    keyProviderOptions: {
      ratchetSalt: new TextEncoder().encode("LKFrameEncryptionKey"),
      ratchetWindowSize: 16,
      failureTolerance: -1,
    },
  },
  hidden: true,
});
Give this a try and let me know if it sorts things out or if you want me to help with anything else! Sources: livekit-ffi/protocol/e2ee.proto | packages/livekit-rtc/src/e2ee.ts
l
SyntaxError: The requested module '@livekit/rtc-node' does not provide an export named 'defaultKeyProviderOptions'
t
Hey there! The error happens because the
@livekit/rtc-node
package doesn’t directly export
defaultKeyProviderOptions
. No worries though—you can set up the
keyProviderOptions
yourself like this:
Copy code
await ctx.connect({
  e2ee: {
    encryptionType: EncryptionType.NONE,
    keyProviderOptions: {
      ratchetSalt: new TextEncoder().encode("LKFrameEncryptionKey"),
      ratchetWindowSize: 16,
      failureTolerance: -1,
    },
  },
  hidden: true,
});
This way, you’re explicitly defining the fields needed for
keyProviderOptions
. If you run into any other questions or need a hand, just let me know—I’m here to help! Sources: packages/livekit-rtc/src/proto/e2ee_pb.ts
l
E:\MeetAI\server>npm run start:agent
server@1.0.0 start:agent
node --require dotenv/config agents/transcriptionAgent.js start
{"level":30,"time":1755613108144,"pid":11036,"hostname":"Satyam","version":"0.1.0","msg":"starting worker"} {"level":30,"time":1755613108209,"pid":11036,"hostname":"Satyam","msg":"Server is listening on port 8081"} {"level":30,"time":1755613108686,"pid":11036,"hostname":"Satyam","version":"0.1.0","id":"AW_w3dcBHjVJkPh","server_info":{"edition":"Cloud","version":"1.9.0","protocol":16,"region":"India","nodeId":"NC_OMUMBAI1B_ARVzQyMKGsbi","debugInfo":"","agentProtocol":0},"msg":"registered worker"} {"level":30,"time":1755613124301,"pid":11036,"hostname":"Satyam","version":"0.1.0","job":{"id":"AJ_RWFAo7qFRYpC","type":"JT_ROOM","room":{"sid":"RM_gZZtYZs4sGv6","name":"test","emptyTimeout":300,"maxParticipants":0,"creationTime":"1755613123","turnPassword":"","enabledCodecs":[{"mime":"audio/red","fmtpLine":""},{"mime":"video/H264","fmtpLine":""},{"mime":"video/VP8","fmtpLine":""},{"mime":"video/VP9","fmtpLine":""},{"mime":"video/AV1","fmtpLine":""},{"mime":"audio/opus","fmtpLine":""}],"metadata":"","numParticipants":0,"activeRecording":false,"numPublishers":0,"version":{"unixMicro":"1755613124024681","ticks":0},"departureTimeout":20,"creationTimeMs":"1755613123716"},"namespace":"","metadata":"","agentName":"","state":{"status":"JS_RUNNING","error":"","startedAt":"1755613124153913805","endedAt":"0","updatedAt":"1755613124153913805","participantIdentity":"","workerId":"AW_w3dcBHjVJkPh"},"dispatchId":""},"resuming":false,"agentName":"","msg":"received job request"} {"level":50,"time":1755613124402,"pid":1952,"hostname":"Satyam","pid":1952,"jobID":"AJ_RWFAo7qFRYpC","err":{"type":"Error","message":"cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set","stack":"Error: cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set\n at Object.writeMessage (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10131)\n at _E2eeOptions.toBinary (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/message.js7513)\n at writeMessageField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js37728)\n at writeField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js31717)\n at Object.writeMessage (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10817)\n at _RoomOptions.toBinary (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/message.js7513)\n at writeMessageField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js37728)\n at writeField (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js31717)\n at Object.writeMessage (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js10817)\n at _ConnectRequest.toBinary (file///E/MeetAI/server/node_modules/@bufbuild/protobuf/dist/esm/message.js7513)"},"msg":"cannot encode field livekit.proto.E2eeOptions.encryption_type to binary: required field not set"}
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
l
if i try to connect the room by turning on the mic and camera then i am getting a warning on the console of trying to publish old data, after this i am not getting connected to the room, meanwhile if i try to connect with the mic and camera off then it is working perfectly, what can be the issue?