Skip to content

DataChannel .send InvalidStateError #417

Description

@Avol

I'm sending 24 packets per second and sometimes closed state doesn't fire before my send event happens. I did a check for a ready state right before sending the packet within my application, but on some rare occasions I get this error anyhow. The exception handler doesn't prevent a crash, so the whole application goes down. Could this be simple-peers fault not wrtc's? Any workarounds for this? I'm currently adding a readyState check inside of the lib to check if that helps, will report on if it helped.

try {
		if (internalDC.readyState == 'open')
			internalDC.send(data);
    } catch (error) {
      // TODO(mroberts): Start using the domexception library.
      if (error.message.match(/InvalidStateError/)) {
        error.code = 11;
        error.name = 'InvalidStateError';
      }
      throw error;
    }
/usr/src/app/node_modules/wrtc/lib/datachannel.js:100
      throw error;
      ^

InvalidStateError: InvalidStateError
    at RTCDataChannel.send (/usr/src/app/node_modules/wrtc/lib/datachannel.js:93:18)
    at Peer.send (/usr/src/app/node_modules/simple-peer/index.js:243:17)
    at SCMoveAll (/usr/src/app/src/networking/outgoing.js:245:20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions