2

I am trying to create a one to one video streaming Ionic app. In the app I have a button "Connect", On click of "Connect" the publisher initialized and on click of "Disconnect" button I disconnect the session.What I want it to work like :

  1. Click Connect - Publisher Initialized
  2. Click Disconnect - Session Disconnect
  3. Click Connect - Publisher Initialized (But here I get the error)

Tokbox Republishing issues

OpenTok:Publisher:error _connectivityAttemptPinger should have been cleaned up +0ms

OpenTok:Publisher:error OT.Publisher State Change Failed:  +209ms 'PublishingToSession' cannot transition to 'PublishingToSession'

OpenTok:Publisher:error OT.Publisher.onPublishingTimeout +15s

OpenTok:GlobalExceptionHandler:error OT.exception :: title: Unable to Publish (1500) msg: ICEWorkflow +0ms

OpenTok:Session:error 1500 +0ms Session.publish :: Could not publish in a reasonable amount of time

OpenTok:Session:error 1500 +9ms Session.publish :: Session.publish :: Could not publish in a reasonable amount of time

The code is below:

tokBoxInit() {
if (OT.checkSystemRequirements() == 1) {

  this.session = OT.initSession(this.apiKey, this.sessionId);
  console.log(this.session);
  this.session.connect(this.token, function(error) {
    if (error) {
      console.log("Error connecting: ", error.name, error.message);
    } else {
      console.log("Connected to the session.");
    }
  });

this.publisher = OT.initPublisher('publisher',{insertMode: 'append',width: '100%',height: '100%'});

this.publisher.on({
  streamCreated: function (event) {},
  streamDestroyed: function (event) {}
});

this.session.on({
    sessionConnected: (event: any) => {
    console.log("Session Connected Listener");
    this.connected = true; // Status to show Connect/Disconnect Button
    this.session.publish(this.publisher);
    }
  });
  }
}
  • What solved this for me while developping with blazor (webassembly, one-page app, so cannot reload from scratch) is this answer, basically if we have display elements not created dynamically sdk would have undisposed stuff in memory when disconnecting: https://stackoverflow.com/a/59509052/7149454 – Nick Kovalsky Jul 21 '20 at 14:49
  • 1
    also i have a feeling this mess was maybe due to publisher options 'append' instead of 'replace'.. – Nick Kovalsky Jul 21 '20 at 16:45

1 Answers1

0

How do you handle the disconnect functionality? Do you clear the session after the connection is destroyed and unpublish the destroyed session?

And also check your token capabilities if it has the role of publisher or moderator as it could also be that the token does not have those properties. Or is missing when the session is regenerated.

1500 error message as quoted by opentok has the following description:

Unable to Publish. The client's token does not have the role set to publish or moderator. Once the client has connected to the session, the capabilities property of the Session object lists the client's capabilities.

But code is too simple to tell, because I can't see how you handle session disconnection so check if you handle it and clear session when disconnected.

  • I am simply unpublish the session and then disconnect. `this.session.unpublish(this.publisher) this.session.disconnect()` – Prateek Tyagi Jun 24 '20 at 11:12
  • Ok Prateek please try this, attach an event to the connect button and let it trigger the publisher to publish to the session only when is clicked and also with the disconnect button too attach an event to listen for when clicked inside the code so that they all work during the session. Because it seems you loose the session after the first time you publish so it cannot publish again. So try to let them work during the session by attaching listeners while the session is active. – Lance Armah-Abraham Jun 25 '20 at 13:56