Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Second Session - Publishing issues


Level 2


I am working on some code for P2P audio chat.  When two users wish to chat, I create a room (server-side) - all rooms are created using the same Room Template.

For each user entering the audio chat, I connect using the following steps:

  1. Create a new session using the new room name in the URL (session = new ConnectSession()).
  2. Login to the session (session.login) and watch for the SYNCHRONIZATION_CHANGED event.
  3. On synchronization_change, if session.isSynchronized:
    • Create an AudioSubscriber (audioSubscriber = new AudioSubscriber()) and subscribe (audioScubscriber.subscribe())
    • Create an AudioPublisher (audioPublisher = new AudioPublisher()), publish and subscribe (audioPublisher.subscribe() and audioPublisher.publish())

For each user leaving the audio chat, I disconnect using the following steps:

  1. Close the AudioSubscriber (audioSubscriber.close())
  2. If the AudioPublisher is publishing, I stop the publisher (audioPublisher.stop()) and wait for the STREAM_DELETE event.
  3. On stream delete, I close the publisher (audioPublisher.close()) and then logout of the session (session.logout()).
  4. Finally, I null out all my references (audioSubscriber = null; audioPublisher = null; session = null) - they are class-level variables.

Everything works perfect when I connect to my first room.  Everyone gets subscribed and published and when I disconnect the users stop subscribing and publishing.  However, when a user has left a room and then tries to connect to a new room (different audio chat), the user fails when publishing with the following error:

Error: AudioPublisher: The stream cannot be published because user does not have permission.
at com.adobe.rtc.collaboration::AudioPublisher/publish()
at Function/<anonymous>()
at com.adobe.rtc.session::ConnectSession/checkManagerSync()
at com.adobe.rtc.sharedManagers::UserManager/userReceivedOrEdited()
at com.adobe.rtc.sharedManagers::UserManager/onItemReceive()
at comm.adobe.rtc.sharedModel::CollectionNode/
at com.adobe.rtc.messaging.manager::MessageManager/
at com.adobe.rtc.session.managers::SessionManagerBase/receiveItem()

If I look at the room, the user is subscribed to the room - so the connect and subscribe worked!!  It is just the publish that is failing.

The connection process is identical each time (other than the room).  The instances of ConnectSession, AudioPublisher and AudioSubscriber are freshly created for each connection.  I'm at a loss for why this is occurring - the only thing I can think of is that the user's session and/or publisher from the first call is not being cleaned up properly on the server causing the second publish to fail.  But that's purely speculation.

I would greatly appreciate any help in resolving this issue!

0 Replies


Level 2

One piece of additional information.  I tried modifying the user's name by adding a sequential number to the end - hoping that because I was creating a new session based on a new user name that it would not have issues publishing.  However, the same error still occurs.


Level 2

I found a earlier post about ConnectSession garbage collection that pointed me in the right direction...

I've stopped recreating the session for each call - as I understand it the second time I create it there is a primarySession variable that gets out of sync.  Now I just logout of the session and change the roomURL, which seems to correct the issue.  Just wanted to provide the answer for others that might run into the same issue down the road.