I want to send streaming data (as sequences of ArrayBuffer
) from a Chrome extension to a Chrome App, since Chrome message API (includes chrome.runtime.sendMessage
, postMessage
...) does not support ArrayBuffer
and JS arrays have poor performance, I have to try other methods. Eventually, I found WebRTC over RTCDataChannel
might a good solution in my case.
I have succeeded to send string over a RTCDataChannel
, but when I tried to send ArrayBuffer
I got:
code: 19
message: "Failed to execute 'send' on 'RTCDataChannel': Could not send data"
name: "NetworkError"
It seems that it's not a bandwidths limits problem since it failed even though I sent one byte of data. Here is my code:
pc = new RTCPeerConnection(configuration, { optional: [ { RtpDataChannels: true } ]});
//...
var dataChannel = m.pc.createDataChannel("mydata", {reliable: true});
//...
var ab = new ArrayBuffer(8);
dataChannel.send(ab);
Tested on OSX 10.10.1, Chrome M40 (Stnble), M42(Canary); and on Chromebook M40.
I have filed a bug for WebRTC here.