Opentok.js on escaping stop (Cannot read "connection" null properties)

I am trying to implement screen sharing with TokBox service in chrome and chrome. After the chrome buttons to select the window work correctly, but when I stop accessing the screen by clicking the Stop Sharing button in the popup that appears when starting screen sharing, the error occurs:

Uncaught TypeError: Cannot read property 'connections' of null ---- opentok.js line 11103

When using tokbox meet demo in the same browser, this error doesn't happen:

I modified the basic code of the tokbox tutorial to reproduce this issue:

<div id="camera"></div>
<div id="screen-preview"></div>
<div id="screen"></div>

<script src="//"></script>

<script type="text/javascript">

  // Go to to find your OpenTok
  // API key and generate a test session ID and token:
  var apiKey    = "<%= api_key %>";
  var sessionId = "<%= session_id %>";
  var token     = "<%= token %>";

  var session = OT.initSession(apiKey, sessionId);

  session.connect(token, function(error) {
    var publisher = OT.initPublisher('camera');

  session.on('streamCreated', function(event) {
    session.subscribe(, 'screen');

  // For Google Chrome only, register your extension by ID. You can
  // find it at chrome://extensions once the extension is installed.
  OT.registerScreenSharingExtension('chrome', '<%= chrome_extension_id %>');

  function screenshare() {
    OT.checkScreenSharingCapability(function(response) {
      if (!response.supported || response.extensionRegistered === false) {
        alert('This browser does not support screen sharing.');
      } else if (response.extensionInstalled === false) {
        alert('Please install the screen sharing extension and load your app over https.');
      } else {
        // Screen sharing is available. Publish the screen.
        var screenSharingPublisher = OT.initPublisher(
          {videoSource : 'screen'},
          function(error) {
            if (error) {
              alert('Something went wrong: ' + error.message);
            } else {
                function(error) {
                  if (error) {
                    alert('Something went wrong: ' + error.message);



source to share

All Articles