Event subscription times out

Hi, I’m having a problem subscribing to an event using SUI TS SDK. Code below:

const watchForEvents = async () => {
  console.log("starting watch");
  const filter: SuiEventFilter = {
    Package: "{Package_id}",
    Module: "{module_name}",
    MoveEventType:
      "{Package_id}::{module_name}::{Event_name}",
    EventType: "MoveEvent",
  };

  await provider.subscribeEvent(
    filter,
    (event: SuiEventEnvelope) => {
      console.log("event received");
      console.log(event);
    }
  );

  console.log("watching...");
};

Getting the following error after a few seconds when starting the node server:

[1] Error: Error subscribing to event: Error: timeout, filter: {Filter info}
[1]     at WebsocketClient.subscribeEvent ({app_dir}\node_modules\@mysten\sui.js\dist\index.js:2025:13)

Is this a problem with the SDK or am I doing something wrong?

10 Likes