Simple-peer: DOMException: Failed to execute 'send' on 'RTCDataChannel': Could not send data

Created on 10 Apr 2017  路  4Comments  路  Source: feross/simple-peer

Exception thrown when trying to peer.send() large amounts of data very quickly.

I think this is to do with the datachannel limiting. Unfortunately the channel closes right after, so we can't just retry later.

Should we buffer data when we can't send it? Or is there a better way to do this outside of simple-peer?

question

Most helpful comment

peer.send() just calls the underlying datachannel.send() method. It is very low-level and doesn't check to see that sending will work.

If you use peer.write() or pipe to the stream instead, you shouldn't have any issues. Note that we get peer.write() because we inherit from the stream.Duplex class.

You can see how we handle backpressure here: https://github.com/feross/simple-peer/blob/00d6b40f3758ffe26551bfae6fa18a9b17edf01f/index.js#L361 but that property is not exposed.

All 4 comments

I saw you hit this issue on instant.io @feross. What was your solution?

Is there some kind of property on the datachannel that we can expose to know if it's ready to send?

Issue doesn't occur when piping.

peer.send() just calls the underlying datachannel.send() method. It is very low-level and doesn't check to see that sending will work.

If you use peer.write() or pipe to the stream instead, you shouldn't have any issues. Note that we get peer.write() because we inherit from the stream.Duplex class.

You can see how we handle backpressure here: https://github.com/feross/simple-peer/blob/00d6b40f3758ffe26551bfae6fa18a9b17edf01f/index.js#L361 but that property is not exposed.

FWIW, Firefox is about to ship an improvement that allows you to call peer.send() with data up to 1GB (!!) More info here: https://bugzilla.mozilla.org/show_bug.cgi?id=979417

Was this page helpful?
0 / 5 - 0 ratings

Related issues

saagarbethi picture saagarbethi  路  4Comments

scriptonist picture scriptonist  路  5Comments

measwel picture measwel  路  4Comments

olgeorge picture olgeorge  路  5Comments

feross picture feross  路  4Comments