title: Chromecast Receiver Application Fails to Launch With Error Code 15
body: <p>While trying to launch a custom receiver application, onApplicationConnectionFailed is occasionally called with Error Code 15. Other times, the application launches successfully, but onApplicationConnected is never called.</p>
  
  <p>I thought maybe it was my sender application code, but I switched all connection logic to now use the Cast Companion Library, and I'm still seeing the same issues. </p>
  
  <p>I've loaded the receiver application in a browser, and I'm not seeing any javascript errors.  </p>
  
  <p>Here is the receiver application code for window.onload:</p>
  
  <pre><code>window.onload = function() {
      cast.receiver.logger.setLevelValue(cast.receiver.LoggerLevel.DEBUG);
      window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
      console.log('Starting Receiver Manager');
  
      // initialize the CastReceiverManager with an application status message
      window.castReceiverManager.start({statusText: "Application is starting"});
  
      // handler for the 'ready' event
      castReceiverManager.onReady = function(event) {
        console.log('Received Ready event: ' + JSON.stringify(event.data));
        window.castReceiverManager.setApplicationState("Application status is ready...");
      };
  
      // handler for 'senderconnected' event
      castReceiverManager.onSenderConnected = function(event) {
        console.log('Received Sender Connected event: ' + event.data);
        console.log(window.castReceiverManager.getSender(event.data).userAgent);
  
      };
  
      // handler for 'senderdisconnected' event
      castReceiverManager.onSenderDisconnected = function(event) {
        console.log('Received Sender Disconnected event: ' + event.data);
        if (window.castReceiverManager.getSenders().length == 0) {
          window.close();
        }
      };
  
      // handler for 'systemvolumechanged' event
      castReceiverManager.onSystemVolumeChanged = function(event) {
        console.log('Received System Volume Changed event: ' + event.data['level'] + ' ' +
            event.data['muted']);
      };
  
      // create a CastMessageBus to handle messages for a custom namespace
      window.messageBus =
        window.castReceiverManager.getCastMessageBus(
            'urn:x-cast:com.wolfgang.chromecasttest.app');
  
      // handler for the CastMessageBus message event
      window.messageBus.onMessage = function(event) {
        console.log('Message [' + event.senderId + ']: ' + event.data);
        // display the message from the sender
        var sentMessage = JSON.parse(event.data);
        if(sentMessage.command == 'MESSAGE'){
          displayText(sentMessage.payload);
          window.messageBus.send(event.senderId, sentMessage.payload);
        } else if(sentMessage.command == 'AUDIO_UPDATE'){
          console.log('GOT BASE64 AUDIO: ' + sentMessage.payload);
          translateAudio(sentMessage.payload);
          window.messageBus.send(event.senderId, 'Audio Update Received');
        } else if(sentMessage.command == 'IPUPDATE'){
          deviceIP = sentMessage.payload;
          reloadImage();
        } else{
          window.messageBus.send(event.senderId, 'Invalid Message Sent');
        }
        // inform all senders on the CastMessageBus of the incoming message event
        // sender message listener will be invoked
  
      }
  
  
      console.log('Receiver Manager started');
  
  
  
    };
  </code></pre>