# Multiple sessions chats not working

**URL:** <https://openvidu.discourse.group/t/multiple-sessions-chats-not-working/2798>\
**Category:** Issues developing apps\
**Tags:** v2\
**Created:** [March 8, 2021, 11:10pm UTC](https://openvidu.discourse.group/t/multiple-sessions-chats-not-working/2798 "2021-03-08T23:10:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefano](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/stefano/32/1382_2.png) [@Stefano](https://openvidu.discourse.group/u/Stefano)\
**Post date:** [March 8, 2021, 11:10pm UTC](https://openvidu.discourse.group/t/multiple-sessions-chats-not-working/2798/1 "2021-03-08T23:10:17Z")

</div>

Hi everybody,  
I’m developing a testbed website with openvidu-browser API 2.16, which would allow the users to join multiple sessions in order to chat with various users at the same time. I’ve adapted the [insecure-js](https://docs.openvidu.io/en/2.17.0/tutorials/openvidu-insecure-js/) example.  
I’m noticing a quite weird behaviour since both the signal and the publish methods refer to the last-joined session instead of the source one:

1. a browser client “A” starts 3 sessions (session1, session2 and then session3)  
which leads to spin 3 sessions running with 3 different tokens (OK)
2. another browser client “B” joins only the first one (session1) (OK)
3. the client “A” starts chatting on session1 with every available user on that session (session1.signal() with empty “to” array to set the message to broadcast) (OK)
4. right after sending out the message, the [signal event](https://docs.openvidu.io/en/2.17.0/api/openvidu-browser/classes/signalevent.html) caught on the **session1** session1.on(‘signal’, (event) =\> {…  
is reported to be originated from and targeting to **session3** (as logged by SignalEvent.from.session and SignalEvent.target.sessionId)
5. the client “B” isn’t receiving the message (since its connected to the session1 only)

By testing a few different combinations seems to me that the same misbehavior affects publishing: the last joined session is always taken instead of the source one.  
Since the program is quite simple (it’s basically just the insecure-js example loop adapted to run three sessions from the same page) I’d guess to be it a server-side issue? I’m running an AWS stack deployed as described [here](https://docs.openvidu.io/en/2.17.0/deployment/deploying-aws/)

Thanks  
Stefano

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [March 9, 2021, 9:49am UTC](https://openvidu.discourse.group/t/multiple-sessions-chats-not-working/2798/2 "2021-03-09T09:49:00Z")

</div>

Hi. You must manage different OpenVidu objects in this special use case.  
For every different Session you want to manage in the very same browser/app tab, you must init a `new OpenVidu()` object. It is that simple.

Regards.

---

<div class="post-metadata">

**Author:** ![Stefano](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/stefano/32/1382_2.png) [@Stefano](https://openvidu.discourse.group/u/Stefano)\
**Post date:** [March 9, 2021, 1:22pm UTC](https://openvidu.discourse.group/t/multiple-sessions-chats-not-working/2798/3 "2021-03-09T13:22:04Z")

</div>

Ok, thank you for such a quick answer!  
I guess that’s about each OV instance managing a single session (be it the only or last one)?  
I’ll refactor asap the testbed according to your suggestion.

Thx  
Stefano
