We are moving to a new platform to serve you better! Stay tuned and watch out for our email on your inbox! [close]
Start a new topic

v0.6.6+: Sending stream after User has joined the Room from SkylinkJS is not received by the mobile SDKs ( both Android / iOS SDK )

What was the cause of the issue

The Android and iOS SDK do not support re-negotiation (or restarts). However, in SkylinkJS sending stream [sendStream()] after joining the room [joinRoom()] initiates a re-negotiation when a User is in a Room and connected with other Peers. As a result,  the sending stream from the SkylinkJS SDK is not reflected in the Android and iOS SDK.

The following methods would result in a re-negotiation if called after a User is connected to Peers in the Room:

sendStream() method

shareScreen() method

stopScreen() method

Workarounds to resolve this

My application does not need to joinRoom() before sendStream() 

If it is not imperative for your application to connect to peers before deciding to sendstream, You can rewrite using the following mechanism.

1. Instead of joinRoom(), call joinRoom({video:true, audio:true});  (or)

2. Call getUserMedia() before calling joinRoom()

My application needs to call joinRoom() before sendStream() 

However, if it is your application's usecase to sendStream() after joinRoom(), you can achieve this by restructuring your app to maintain interoperability with the mobile SDKs.

Every time your application needs to using one of the methods mentioned above (sendStream, shareScreen, stopScreen), you would need to rejoin the room. So ensure that you use your own user ID as an identifier for your User's session and set it in the userData object and instead of the peerId as the identifier for the User's session.

This is to avoid your application incorrectly detecting the re-join as a new peer instead of an existing peer refreshing the connection. 

Code Sample:

var userData = {
  userId: skylink.generateUUID(),
  name: "user-input-name"

function sendStream (sendAudio, sendVideo) {
   // Reflect in UI that User is sending stream
      userData: userData,
      audio: sendAudio,
      video: sendVideo
   }, function (jRErr, jRSuccess) {
      console.log("User has sent stream");

function shareScreen (sendAudio) {
   // Reflect in UI that User is sending stream (screensharing)
   skylink.once("mediaAccessSuccess", function (stream, isScreensharing) {
      if (isScreensharing) {
            userData: userData
         }, function (jRErr, jRSuccess) {
            console.log("User has sent stream (screensharing)");

skylink.on("peerJoined", function (peerId, peerInfo, isSelf) {
   if (isSelf) return;
   var peer = document.createElement("div");
   peer.id = peerInfo.userData.userId;

skylink.on("incomingStream", function (peerId, stream, isSelf, peerInfo) {
   if (isSelf) {
      attachMediaStream(stream, document.getElementById("me-video");
   var video = document.getElementById(peerInfo.userData.userId + "-video");
   if (!video) {
      video = document.createElement("video");
      video.id = peerInfo.userData.userId + "-video";
      video.autoplay = true;
      video.muted = false;
   attachMediaStream(stream, video);

skylink.on("peerLeft", function (peerId, peerInfo, isSelf) {
   if (isSelf) return;
   var peer = document.getElementById(peerInfo.userData.userId);
   if (peer) {

   appKey: "xxxxx",
   defaultRoom: "the-fixed-room-name"
}, function (initErr, initSuccess) {
   if (initErr) return;
     userData: userData
   }, function (jRErr, jRSuccess) {
     if (jRErr) return;
     console.log("User has joined the room");


Login or Signup to post a comment