0

I am trying to make a simple peer to peer video chat. at first i tried using webkit, the connection was made but couldn't make webkit work for cross browser.

Then I started working with peer js. I was following the feross/simple-peer package in github. At first I have tried to make a data connection. Then i would go trying sending stream. Now the data connection establishing was working fine in cross browser. But suddenly it stopped working in mozilla. showing error about "TURN server". But the same code was working cross browser just a few days ago. Here is the code:

<html>
  <body>
    <style>
      #outgoing {
        width: 600px;
        word-wrap: break-word;
        white-space: normal;
      }
    </style>
    <form>
      <textarea id="incoming"></textarea>
      <button type="submit">submit</button>
    </form>
    <pre id="outgoing"></pre>
    <script src="simplepeer.min.js"></script>
    <script>
      const p = new SimplePeer({
        initiator: location.hash === '#1',
        trickle: false
      })

      p.on('error', err => console.log('error', err))

      p.on('signal', data => {
        console.log('SIGNAL', JSON.stringify(data))
        document.querySelector('#outgoing').textContent = JSON.stringify(data)
      })

      document.querySelector('form').addEventListener('submit', ev => {
        ev.preventDefault()
        p.signal(JSON.parse(document.querySelector('#incoming').value))
      })

      p.on('connect', () => {
        console.log('CONNECT')
        p.send('whatever' + Math.random())
      })

      p.on('data', data => {
        console.log('data: ' + data)
      })
    </script>
  </body>
</html>
Rafaeatul
  • 43
  • 8
  • Please provide the exact error message. – Christoph Nov 19 '19 at 09:38
  • Did you try all the troubleshooting steps as described here? https://github.com/feross/simple-peer/issues/202 If your issue, still persists, report back which step failed with exact details. – Christoph Nov 19 '19 at 09:50

0 Answers0