How to access observer-api

according to docs Observer API should be used by third -party library and not directly i have Observer.js

const mediasoup = require("mediasoup");"newworker", (worker) =>
  console.log("new worker created []",;

if i run it as another app using expressjs at the same directory it not handling main app event its work only when i includeit in the main app

I think the only way to make it work is to include this Observer.js into your main server app code. If you run it as a separate server then I don’t think it will work.

It is also mentioned in the docs: “The observer API should not be directly used by the application itself, but by separate modules or libraries that the application integrate into its code”. You see “the libraries that the application integrate into its code”, not “in separate app”.

All threads/processes are locked to a heap of memory a range if you will, you cannot run two apps (in many languages) and expect them to share memory, this is the dream for many of us so we don’t need to broker data (fan it out).

In your case, you run two processes and one can never see the other, Node.JS spawns the MediaSoup worker but only the process that summoned it can communicate with it.

This won’t be possible without you signaling from your media soup server to your observer app. This can be very inefficient and so I’d recommend it just for development only.

If you need user-stats or other details, try to make that a client-sided job.

1 Like