【问题标题】:RTCQuicTransport: The provided value cannot be converted to a sequenceRTCQuicTransport:提供的值不能转换为序列
【发布时间】:2019-07-05 05:15:29
【问题描述】:

当我尝试在 Javascript 上调用 RTCQuicTransport 的构造函数时,它会抛出错误:Uncaught TypeError: Failed to construction 'RTCQuicTransport': The provided value cannot be convert to a sequence.

假设构造函数需要两个参数,一个 RTCIceTransport 对象和一个使用 RTCPeerConnection.generateCertificate() 生成的证书,它应该以这种方式工作,但不是。

我尝试将“null”作为证书传递,但仍然抛出相同的错误消息。如果我只是传递 RTCIceTransport 对象,它会抛出该构造需要两个参数。

// Include some helper functions
//import {trace, errorHandler, mySendLocalCandidate, 
myIceGathererStateChange,
//  myIceTransportStateChange, myDtlsTransportStateChange} from 'helper';
//import 'helper.js';

function initiate(mySignaller) {
// Prepare the IceGatherer
var gatherOptions = {
  gatherPolicy: "all",
  iceServers: [
    { urls: "stun:stun1.example.net" },
    { urls: "turn:turn.example.org", username: "user", credential: 
    "myPassword",
      credentialType: "password" }
   ]
};

// Create the IceTransport
var ice = new RTCIceTransport();
ice.onstatechange = function(event) {
  myIceGathererStateChange("iceGatherer", event.state);
};
// Handle errors
// Prepare to signal local candidates
ice.onlocalcandidate = function(event) {
  mySignaller.mySendLocalCandidate(event.candidate);
};

// Start gathering
ice.gather(gatherOptions);

// Prepare to handle remote ICE candidates
console.log(ice);
mySignaller.onRemoteCandidate = function(remote) {
  ice.addRemoteCandidate(remote.candidate);
};

// Create the certificate
var certs = {};
var keygenAlgorithm = { name: "ECDSA", namedCurve: "P-256"};

RTCPeerConnection.generateCertificate(keygenAlgorithm).
then(function(certificate){
  certs[0] = certificate;
}, function(){
  trace('Certificate could not be created');
});
// Create the DtlsTransport and QuicTransport
var quic = new RTCQuicTransport(ice, certs[0]);
console.log(quic);
mySignaller.sendInitiate({
  ice: iceGatherer.getLocalParameters(),
  quic: quic.getLocalParameters(),
  // ... marshall RtpSender/RtpReceiver capabilities as in Section 6.6 
Examples 8 and 9.
}, function(remote) {
  // Start the IceTransport, DtlsTransport and QuicTransport
  ice.start(iceGatherer, remote.ice, RTCIceRole.controlling);
  dtls.start(remote.dtls);
  quic.start(remote.quic);
  // ... configure RtpSender/RtpReceiver objects as in Section 6.6 
Examples 8 and 9.
});}

我正在关注 ORTC quic 示例,我希望获得一个 RTCQuicTransport 对象。

提前致谢

编辑

我意识到当我在 generateCertificate() 函数中打印我的证书时,它可以正常工作:

RTCCertificate {expires: 1552505428000}
expires: 1552505428000

但是,从那个函数中,我得到了这个:

console.log(certs);

结果:

{}
  [0] RTCCertificate
      expires: 1552505951000

那我试试:

console.log(certs[0]);

结果:

undefined

【问题讨论】:

  • 确保以可搜索、可复制、格式化的文本(通过edit)显示准确和完整的错误和跟踪。
  • 您是否正在尝试developers.google.com/web/updates/2019/01/rtcquictransport-api 中描述的 Chrome 实验?不幸的是,该实验不符合规范。 webrtchacks.com/first-steps-with-quic-datachannel 有另一个描述以及运行代码。
  • 感谢@jdv 的推荐
  • 菲利普,嗨。我已经尝试过 ORTC API 规范中的示例代码:draft.ortc.org/#rtcquicexample* 此代码无法运行,因为只有 Edge 浏览器支持 RTCIceGatherer,但是,我修改了代码以获取 RTCQuicTransport 所需的 RTCIceTransport 对象。我尝试了您引用的 api“developers.google.com/web/updates/2019/01/rtcquictransport-api”,但由于 RTCQuicTransport 对象是从 2 个参数(IceTransport 对象、证书)创建的,因此该代码不起作用。感谢第二次参考,我去看看试试
  • 遗憾的是,Edge 不支持 QUICTransport。

标签: javascript google-chrome webrtc chromium quic


【解决方案1】:

与 RTCIceTransport 和 RTCQuic 传输兼容的网络浏览器是 Chrome 73 Beta 版,据此:RTCQuicTransport over chrome 虽然我试图在带有 --enable-blink-features=RTCQuicTransport,RTCIceTransportExtension 标志的 chrome 72 中运行它,但这还不够。

在 chrome 73 beta 中,我可以通过传递 null 作为第二个参数并生成我自己的证书来创建 RTCQuicTransport。

【讨论】:

    猜你喜欢
    • 2015-11-24
    • 2019-01-13
    • 2019-05-29
    • 1970-01-01
    • 1970-01-01
    • 2011-12-25
    • 1970-01-01
    • 2019-08-03
    • 2012-04-01
    相关资源
    最近更新 更多