# How to access observer-api

**URL:** <https://mediasoup.discourse.group/t/how-to-access-observer-api/4365>\
**Category:** mediasoup libraries\
**Created:** [July 9, 2022, 1:53am UTC](https://mediasoup.discourse.group/t/how-to-access-observer-api/4365 "2022-07-09T01:53:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![musta20](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@musta20](https://mediasoup.discourse.group/u/musta20)\
**Post date:** [July 9, 2022, 1:53am UTC](https://mediasoup.discourse.group/t/how-to-access-observer-api/4365/1 "2022-07-09T01:53:38Z")

</div>

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

```auto
Observer.js
const mediasoup = require("mediasoup");

mediasoup.observer.on("newworker", (worker) =>
{
  console.log("new worker created [worke.pid:%d]", worker.pid);
})

```

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

> **[mediasoup :: API](https://mediasoup.org/documentation/v3/mediasoup/api/#observer-api)**
>
> Cutting Edge WebRTC Video Conferencing

---

<div class="post-metadata">

**Author:** ![zaidiqbal](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/zaidiqbal/32/1498_2.png) [@zaidiqbal](https://mediasoup.discourse.group/u/zaidiqbal)\
**Post date:** [July 9, 2022, 6:42am UTC](https://mediasoup.discourse.group/t/how-to-access-observer-api/4365/2 "2022-07-09T06:42:34Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [July 11, 2022, 10:20pm UTC](https://mediasoup.discourse.group/t/how-to-access-observer-api/4365/3 "2022-07-11T22:20:03Z")

</div>

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.
