title: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection'
body: <p>I am trying to set up a webrtc signaling service using <a href="https://github.com/mafintosh/signalhub" rel="nofollow noreferrer">SignalHub</a> and <a href="https://github.com/feross/simple-peer" rel="nofollow noreferrer">SimplePeer</a>. But when executing I get the following error: <code>Uncaught (in promise) Error: InvalidStateError: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: kStable</code>.</p>
  
  <p>Here is the code: </p>
  
  <pre><code>navigator.mediaDevices.getUserMedia({video: true, audio: false})
  .then((stream) =&gt; {
      const signalhub = require('signalhub')
      const hub = signalhub('live-video', [
          'http://localhost:8080'
      ])
      const Peer = require('simple-peer')
      const peer = new Peer({
          initiator: location.hash == '#init',
          trickle: false,
          stream: stream
      })
  
      peer.on('signal', (data) =&gt; {
          let yourID = JSON.stringify(data)
          console.log('your ID: ', yourID)
          hub.broadcast('update', yourID)
      })
  
      hub.subscribe('update').on('data', (data) =&gt; {
          let otherID = JSON.parse(data)
          console.log('other ID: ', otherID)
          peer.signal(otherID)
      })
  
      // peer.on('stream', (stream) =&gt; {
      //     const video = document.createElement('video')
      //     document.body.appendChild(video)
  
      //     video.src = window.URL.createObjectURL(stream)
      //     video.play()
      // })
  })
  .catch((err) =&gt; {
      document.write(err)
  })
  </code></pre>
  
  <p>I've followed those two tutorials <a href="https://www.youtube.com/watch?v=ieBtXwHvoNk" rel="nofollow noreferrer">P2P Video Chat with JavaScript / WebRTC</a> &amp; <a href="https://www.youtube.com/watch?v=jY9k4rfXwEI" rel="nofollow noreferrer">P2P Signaling for WebRTC with SignalHub</a> by Kyle Robinson Young.</p>