Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when creating second DataChannel. #127

Open
t-mullen opened this issue Jun 14, 2018 · 2 comments
Open

Error when creating second DataChannel. #127

t-mullen opened this issue Jun 14, 2018 · 2 comments

Comments

@t-mullen
Copy link

t-mullen commented Jun 14, 2018

Trying to create 2 datachannels in a row fails with an error.

var wrtc = require('electron-webrtc')()
var pc = new wrtc.RTCPeerConnection({})
 
pc.createDataChannel('label1', {})
pc.createDataChannel('label2', {})
Error: Error evaluating "
        var pc = conns["0"]
        var dc = pc.dataChannels[65535]

        var id = 'dc:' + "0" + ':' + dc.id
        dc.onopen = function () {
          send(id, {
            type: 'open',
            state: {
              ordered: dc.ordered,
              protocol: dc.protocol,
              maxPacketLifeType: dc.maxPacketLifeType,
              maxRetransmits: dc.maxRetransmits,
              negotiated: dc.negotiated,
              reliable: dc.reliable
            }
          })
        }
        dc.onmessage = function (e) {
          send(id, {
            type: 'message',
            event: {
              data: e.data instanceof ArrayBuffer ? arrayBufferToBase64(e.data) : e.data,
              origin: e.origin
            },
            dataType: e.data instanceof ArrayBuffer ? 'binary' : 'string'
          })
        }
        dc.onbufferedamountlow = function () {
          send(id, { type: 'bufferedamountlow' })
        }
        dc.onclose = function () {
          delete pc.dataChannels[dc.id]
          send(id, { type: 'close' })
        }
        dc.onerror = function () {
          send(id, { type: 'error' })
        }
        if (dc.readyState === 'open') dc.onopen()
        for (var i = 0; i < dc.msgQueue.length; i++) {
          dc.onmessage(dc.msgQueue[i])
        }
        dc.msgQueue = null
      " in "window": Cannot read property 'length' of null
    at Daemon.<anonymous> (/Users/Mullen/Desktop/Projects/Web/Working/simple-peer/node_modules/electron-eval/lib/index.js:81:21)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at Daemon.emit (events.js:211:7)
@t-mullen
Copy link
Author

t-mullen commented Jun 15, 2018

dc.id is always 65535, which is leading to a conflict.

@t-mullen
Copy link
Author

t-mullen commented Jun 15, 2018

It looks like the non-uniqueness of ids is normal. (Happens in Chrome and Firefox too).

Since they aren't unique, using them for the pc._dataChannels map is incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant