Handle Screen share correctly


I have deployed jitsi on custom server and custom web app along with it , using the jitsi low level API.

The Problem :
On the first screen share , the screen-share works correctly and all the participants in the room are able to see it correctly without any issue, the issue comes when the same participant tries to screen-share for the 2nd time , the screen-share is not being shared. Assuming the issue is on how i am trying to stop the screen share initially. Please advice on how the screen-share should be stopped.

The understanding and implementation as of now:
On initial screenshare , the track is created :

// Create the desktop tracks
 try {
    desktopTracks = await JitsiMeetJS.createLocalTracks({
      devices: ["desktop"],
  } catch (e) {
    if (e && e.name === "gum.permission_denied") {
          "Screenshare permission denied. Please give permissions manually."

// add tracks

On screen share end

try {
      await jitsiConference.removeTrack(myDesktopTrack);
    } catch (e) {

    try {
      await myDesktopTrack.dispose();
    } catch (e) {

Jitsi Config :

  enableNoAudioDetection: false,
  enableNoisyMicDetection: false,
  useIPv6: false,
  disableAudioLevels: true,
  enableWindowOnErrorHandler: false,
  disableThirdPartyRequests: false,
  enableAnalyticsLogging: false,
  enableLayerSuspension: true,
  disableSimulcast: false,
  videoQuality: {
    preferredCodec: "VP8",
    enforcePreferredCodec: false,
  clientNode: "http://jitsi.org/jitsimeet",
  useNicks: false,
  getWiFiStatsMethod: null,
  useStunTurn: true,
  p2p: {
    enabled: false,
    useStunTurn: true,
    stunServers: [{ urls: "stun:meet-jit-si-turnrelay.jitsi.net:443" }],
  analytics: {},
  deploymentInfo: {},
  e2eping: {
    pingInterval: -1,
  disableRtx: true,

Thank you

@jallamsetty Any suggestions on this please ? Thanks for your time.

When stopping SS, please call JitsiConference.replaceTrack(currentTrack, null) and when you need to start SS again, call JitsiConference.replaceTrack(currentTrack, newDesktopTrack). Please try this out and see if it fixes your issue.