Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Second Session - Publishing issues

Avatar

Level 2

Hi,

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 flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.adobe.rtc.session::ConnectSession/checkManagerSync()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at com.adobe.rtc.sharedManagers::UserManager/userReceivedOrEdited()
at com.adobe.rtc.sharedManagers::UserManager/onItemReceive()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at comm.adobe.rtc.sharedModel::CollectionNode/http://www.adobe.com/2006/connect/cocomo/messaging/internal::receiveItem()
at com.adobe.rtc.messaging.manager::MessageManager/http://www.adobe.com/2006/connect/cocomo/messaging/internal::receiveItem()
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!

2 Replies

Avatar

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.

Avatar

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.

Thanks!