Skip to content

Error on registering the subscribtion to an event #282

@Mirsagatov

Description

@Mirsagatov

I am trying to subscribe to a ring-central event via @sdk/subscriptions.

useEffect(() => {
    if (!subscriptions || !selectedAccountId || !selectedCompanyId) return;

    const subscription = subscriptions.createSubscription();

    subscription.on(subscription.events.notification, handleTelephonySessionNotification);

    subscription
      .setEventFilters(["/restapi/v1.0/account/~/extension/~/telephony/sessions"])
      .register()
      .then((subscription) => {
        setTelephonySessionsSubscription(subscription);
      })
      .catch((err) => console.error("Failed to register to telephony session notifications", err));

    return () => {
      telephonySessionsSubscription?.revoke();
    };
  }, [subscriptions, selectedAccountId, selectedCompanyId]);

However, I get the following error due to .register():

RingCentralSoftphone.tsx:265 Failed to register to telephony session notifications TypeError: Cannot read properties of undefined (reading 'addEventListener')

When I click the source of the error, this is where I end up:

 setupWsEventListener() {
    this.wse.ws.addEventListener("message", this.eventListener);
  }

I am using React + Typescript + Vite. I have installed nodePolyfills for the ring central sdk to even work.
I found no mention of such an issue anywhere on the Internet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions