discordjs/discord.js · critical · Error

No compatible encryption modes. Available include: ${options

Error message

No compatible encryption modes. Available include: ${options.join(', ')}

What it means

During voice connection setup, chooseEncryptionMode() picks the first server-offered encryption mode that appears in SUPPORTED_ENCRYPTION_MODES. If the voice gateway offers none of the supported modes, the library throws, since secure transport is mandatory.

Source

Thrown at packages/voice/src/networking/Networking.ts:215

 */
function stringifyState(state: NetworkingState) {
	return JSON.stringify({
		...state,
		ws: Reflect.has(state, 'ws'),
		udp: Reflect.has(state, 'udp'),
	});
}

/**
 * Chooses an encryption mode from a list of given options. Chooses the most preferred option.
 *
 * @param options - The available encryption options
 */
function chooseEncryptionMode(options: VoiceEncryptionMode[]): VoiceEncryptionMode {
	const option = options.find((option) => SUPPORTED_ENCRYPTION_MODES.includes(option));
	if (!option) {
		// This should only ever happen if the gateway does not give us any encryption modes we support.
		throw new Error(`No compatible encryption modes. Available include: ${options.join(', ')}`);
	}

	return option;
}

/**
 * Returns a random number that is in the range of n bits.
 *
 * @param numberOfBits - The number of bits
 */
function randomNBit(numberOfBits: number) {
	return Math.floor(Math.random() * 2 ** numberOfBits);
}

/**
 * Manages the networking required to maintain a voice connection and dispatch audio packets
 */
export class Networking extends EventEmitter {

View on GitHub (pinned to a81ed8a306)

Solutions

  1. Update @discordjs/voice (and discord.js) to the latest version so modern modes like aead_xchacha20_poly1305_rtpsize are supported
  2. If constrained to an old environment, install the @snazzah (sodium-native/libsodium-wrappers or tweetnacl) crypto dependency set matching your library version's SUPPORTED_ENCRYPTION_MODES
  3. Check that no proxy/custom voice gateway is stripping the supported modes from the offer
  4. Log the offered modes from the error message and compare against your library's SUPPORTED_ENCRYPTION_MODES

Example fix

// before (old lib, only legacy modes offered)
// "No compatible encryption modes. Available include: xsalsa20_poly1305"
npm i @discordjs/voice@latest
// after: library supports aead_xchacha20_poly1305_rtpsize and connects
Defensive patterns

Strategy: retry

Try / catch

try { connect(); } catch (e) { if (e.message.startsWith('No compatible encryption modes')) { await updateOrReconnectWithSupportedModes(); } else throw e; }

Prevention

When it happens

Trigger: The Discord voice server's select_protocol/description returns VoiceEncryptionMode values (e.g. xsalsa20_poly1305 variants) none of which the installed library supports — typically when the gateway only offers deprecated modes (xsalsa20_poly1305, xsalsa20_poly1305_suffix, xsalsa20_poly1305_post) while the installed @discordjs/voice only supports aead_xchacha20_poly1305_rtpsize (or vice versa with an old library).

Common situations: Outdated @discordjs/voice after Discord deprecated old encryption modes; very new library against a stale/proxy voice gateway; custom self-hosted/patched voice servers offering unsupported modes.

Related errors


AI-assisted analysis of discordjs/discord.js@a81ed8a306 (2026-08-30). Data as JSON: /api/errors/8b4dc3b57eba6807. Report an issue: GitHub.