Dev Admin avatar image
Dev Admin asked Phong Vu answered

Encountering 'Cannot read properties of undefined (reading 'addEventListener')' within my application

/Users/alexpower/Code/Projects/teleingest/node_modules/@rc-ex/ws/lib/subscription.js:22'message', this.eventListener);


TypeError: Cannot read properties of undefined (reading 'addEventListener')

at Subscription.setupWsEventListener (/Users/alexpower/Code/Projects/teleingest/node_modules/@rc-ex/ws/lib/subscription.js:22:21)

at new Subscription (/Users/alexpower/Code/Projects/teleingest/node_modules/@rc-ex/ws/lib/subscription.js:19:14)

at WebSocketExtension.subscribe (/Users/alexpower/Code/Projects/teleingest/node_modules/@rc-ex/ws/lib/index.js:315:30)

at Subscription.<anonymous> (/Users/alexpower/Code/Projects/teleingest/node_modules/@ringcentral/subscriptions/lib/Subscriptions.js:89:58)

at step (/Users/alexpower/Code/Projects/teleingest/node_modules/@ringcentral/subscriptions/lib/Subscriptions.js:48:23)

at (/Users/alexpower/Code/Projects/teleingest/node_modules/@ringcentral/subscriptions/lib/Subscriptions.js:29:53)

at fulfilled (/Users/alexpower/Code/Projects/teleingest/node_modules/@ringcentral/subscriptions/lib/Subscriptions.js:20:58)

at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

const sendMessage = require("./src/sendMessage");
const { SDK } = require("@ringcentral/sdk");
const { Subscriptions } = require("@ringcentral/subscriptions");

const logger = require('pino')(
        messageKey: "message",
        formatters: {
            level: (label) => {
                return { level: label };

const sdk = new SDK({
    server: process.env.RC_ENV !== "production" ? SDK.server.sandbox : SDK.server.production,
    clientId: process.env.RC_CLIENT,
    clientSecret: process.env.RC_SECRET

const platform = sdk.platform();
const subscriptions = new Subscriptions({
    sdk: sdk,

const main = async () => {
    // login
    await platform.login({
        jwt: process.env.RC_JWT,

    // subscribe
    const subscription = subscriptions.createSubscription();
    subscription.on(, (evt) => {
        console.log(JSON.stringify(evt, null, 2));
    await subscription.setEventFilters(['/restapi/v1.0/account/~/telephony/sessions']).register();

    // trigger events
        .then(() =>"Subscribed to events."))
        .catch((err) => {
            logger.error({ err }, err.message)

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered

I have no problem running your code on my machine. Can you update the RingCentral SDK and the Subscription plugin to make sure you get the latest version.



1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys