TokBox Republishing issue - Giving error when try to publishing after unpublish

Viewed 935

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);
    }
  });
  }
}
1 Answers

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.

Related