首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AppRTC服务器返回html而不是Json。

AppRTC服务器返回html而不是Json。
EN

Stack Overflow用户
提问于 2015-01-06 04:46:13
回答 1查看 2.4K关注 0票数 7

我正在将WebRTC本地应用到安卓系统中。我能够像这里所描述的那样编译和运行代码,但是我遇到了一个问题,在这个问题上,http://www.webrtc.org/native-code/android显然没有像设想的那样返回一个通道令牌:

代码语言:javascript
复制
01-05 20:01:51.230  15488-15488/org.appspot.apprtc E/AppRTCDemoActivity﹕ Fatal error: Missing channelToken in HTML: <!DOCTYPE html>
    <!--
    *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
    *
    *  Use of this source code is governed by a BSD-style license
    *  that can be found in the LICENSE file in the root of the source
    *  tree.
    -->
    <html>
    <head>
    <title>WebRTC Reference App</title>
    <meta charset="utf-8">
    <meta name="description" content="WebRTC reference app">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
    <script type='text/javascript'>window.mod_pagespeed_start = Number(new Date());</script><link rel="canonical" href="https://apprtc.appspot.com/room/42272483?r=fh">
    <link rel="stylesheet" href="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/css/A.main.css.pagespeed.cf.mluzaRyZGPUUQu3CIFwW.css">
    </head>
    <body><noscript><meta HTTP-EQUIV="refresh" content="0;url='https://apprtc.appspot.com/r/42272483?r=fh&amp;PageSpeed=noscript'" /><style><!--table,div,span,font,p{display:none} --></style><div style="display:block">Please click <a href="https://apprtc.appspot.com/r/42272483?r=fh&amp;PageSpeed=noscript">here</a> if you are not redirected within a few seconds.</div></noscript>
    <div id="videos">
    <video id="mini-video" autoplay muted></video>
    <canvas id="remote-canvas"></canvas>
    <video id="remote-video" autoplay></video>
    <video id="local-video" autoplay muted></video>
    </div>
    <footer>
    <div id="sharing">
    <div id="room-link">Waiting for someone to join this room: <a href="https://apprtc.appspot.com/room/42272483?r=fh" target="_blank">https://apprtc.appspot.com/room/42272483?r=fh</a></div>
    </div>
    <div id="info"></div>
    <div id="status"></div>
    </footer>
    <script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/stats.js.pagespeed.jm.A-w15PL7V0sRNC026ANH.js"></script>
    <script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/signaling.js.pagespeed.jm.QZ7VRUXKfNhiyV7jHkmW.js"></script>
    <script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/infobox.js.pagespeed.jm.C9t_78UyYtO6bMRljt_L.js"></script>
    <script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/sdputils.js.pagespeed.jm.DWy54ENwSOTLQKw10p1o.js"></script>
    <script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/util.js.pagespeed.jm.q3iuB_S1TC2eBJC_RFlb.js"></script>
    <script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/main.js.pagespeed.jm.mR4sH1O_ReNLDaNiS3o_.js"></script>
    <script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/adapter.js.pagespeed.jm.-Ip1bBjviqtsxeGluAGS.js"></script>
    <script type="text/javascript">var params={errorMessages:[],isLoopback:false,roomId:'42272483',roomLink:'https://apprtc.appspot.com/room/42272483?r=fh',mediaConstraints:{"audio":true,"video":true},offerConstraints:{"optional":[],"mandatory":{}},peerConnectionConfig:{"iceServers":[]},peerConnectionConstraints:{"optional":[{"googImprovedWifiBwe":true}]},turnRequestUrl:'https://computeengineondemand.appspot.com/turn?username=280585048&key=4080218913',turnTransports:'',audioSendBitrate:'',audioSendCodec:'',audioRecvBitrate:'',audioRecvCodec:'',isStereoscopic:'',opusMaxPbr:'',opusFec:'',opusStereo:'',videoSendBitrate:'',videoSendInitialBitrate:'',videoSendCodec:'',videoRecvBitrate:'',videoRecvCodec:'',wssUrl:'wss://apprtc-ws.webrtc.org:443/ws',wssPostUrl:'https://apprtc-ws.webrtc.org:443'};initialize();</script>
    <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.cr

在查看AppRTCClient.java这里的源代码时,https://code.google.com/p/webrtc/source/browse/trunk/talk/examples/android/src/org/appspot/apprtc/AppRTCClient.java?r=5847在第234 of行找到了一条有趣的评论,这正是应用程序失败的地方:

代码语言:javascript
复制
// Fetches |url| and fishes the signaling parameters out of the HTML via
// regular expressions.
//
// TODO(fischman): replace this hackery with a dedicated JSON-serving URL in
// apprtc so that this isn't necessary (here and in other future apps that
// want to interop with apprtc).
private AppRTCSignalingParameters getParametersForRoomUrl(String url)
        throws IOException {

    // ...

}

在这个函数中,对html代码进行了大量的解析,并且似乎没有从服务器返回的响应html中正确地解析通道令牌(这是不足为奇的)。

我没有进一步研究信道令牌是否存在和/或它是否正确。相反,我怀疑代码(主干!)可能是过时的,谷歌搜索,并发现这个项目上的Github:https://github.com/pristineio/webrtc-android

在第232 to行,相同的函数作为参数传入&t=json,据推测是因为它希望服务器返回Json。然后,函数在解析Json时失败,猜猜原因。对啰!因为返回相同的html页,不管参数是带还是不带。

代码语言:javascript
复制
// Fetches |url| and fishes the signaling parameters out of the JSON.
private AppRTCSignalingParameters getParametersForRoomUrl(String url)
        throws IOException, JSONException {
    url = url + "&t=json";

    // ...

}

为了完整起见,失败的完整URL:

代码语言:javascript
复制
https://apprtc.appspot.com/?r=00000000&t=json

00000000是房间号。

因此,在此期间,谷歌的费斯奇曼先生似乎已经更新了代码,但webrtc的代码并不是最新的,Github的pristineio/webrtc-android似乎知道曾经让apprtc.appspot.com返回Json而不是html的参数,但它不再知道。

我搜索了apprtc.appspot.com的服务器代码,但没有找到它,但我记得以前见过它(我相信这是一个Python项目)。

  • 有人有那个源代码的链接吗?

然后,我搜索了该URL的参数,并在其中找到了两个页面,其中包括http://samdutton.github.io/webrtc/samples/web/content/apprtc/params.html,但没有一个页面显示参数或替代URL作为Json请求结果。

  • 有人知道正确的参数(或url)是什么吗?
  • 或者有人知道完整的规格是什么?
  • 或者有人有一个链接到最新的和工作的AppRTCClient.Java源代码?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-06 08:40:31

遇到和你一样的问题。我在这里找到了密码:

https://github.com/GoogleChrome/webrtc/tree/master/samples/web/content/apprtc

目前,通过观察变化,看看是什么可能打破了它。如果我发现什么,我会更新这个答案。

更新:看起来他们在这个提交中做了一些突破性的更改:

https://github.com/GoogleChrome/webrtc/commit/c36b88475fab8a3e4436a87a7ea84265b0e13a8a#diff-c3e41e94913c93dfe31babd4830c3065

他们正在从GAE通道api移动到websocket通道。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27792233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档