webrtc - Google App Engine. Channel API. The provided token is invalid. -
i've been trying make application calling browser browser using webrtc
. wrote simple servlet creating channel:
prefclubchannelservletservlet extends httpservlet { public void dopost(httpservletrequest req, httpservletresponse resp) throws ioexception { string channelkey = req.getparameter("userid"); resp.addheader("access-control-allow-origin", "*"); channelservice channelservice = channelservicefactory.getchannelservice(); string token = channelservice.createchannel(channelkey); resp.setcontenttype("text/plain"); resp.getwriter().println(token); } }
i've deployed in google app engine. in web application i've got page java script, similar https://apprtc.appspot.com. in code caller calls prepare(1)
, , callee – prepare(0).
function prepare(ini) { initiator = ini; card = document.getelementbyid("card"); localvideo = document.getelementbyid("localvideo"); minivideo = document.getelementbyid("minivideo"); remotevideo = document.getelementbyid("remotevideo"); resetstatus(); console.log("try token"); gettoken(); } function gettoken() { var token; if (initiator) { var xhr = new xmlhttprequest(); var url = 'http://pref-club.appspot.com/prefclubchannelservlet?userid=gggg'; xhr.open('post', url, true); // specify body of request contains form data xhr.setrequestheader("content-type", "application/x-www-form-urlencoded"); xhr.send(url); xhr.onreadystatechange = function () { if (xhr.readystate == 4 && xhr.status == 200) { token = xhr.responsetext; console.log("token = " + token); document.getelementbyid("token").value = token; openchannel(token); dogetusermedia(); } }; } else { token = document.getelementbyid("token").value; console.log("token = " + token); openchannel(token); dogetusermedia(); } };
so, both caller , callee use same token open channel, , indeed open channel, got media , made rtcpeerconnection
function openchannel(channeltoken) { console.log("opening channel."); var channel = new goog.appengine.channel(channeltoken); var handler = { 'onopen': onchannelopened, 'onmessage': onchannelmessage, 'onerror': onchannelerror, 'onclose': onchannelclosed }; socket = channel.open(handler); }
the main problem event handler onchannelmessage
doesn't work. don't see s->c: in console log. callee doesn't see offer caller.
then, refreshed servlet, redeployed it, , discovered can't open channel @ all. while opening channel i'm getting uncaught error:
the provided token invalid.
Comments
Post a Comment