通过websocket客户端/服务器连接问题webrtc

不知道是否有人有什么我在做什么错误在这里:

我一直在: http : //blog.felixhagspiel.de/index.php/posts/create-your-own-videochat-application-with-html-and-javascript

该指南工作得很好,我已经通过nodejs进行了testing,所有工作都非常好。

我现在试图把这个例子转换成groovy。 在一个Grails插件中,并遇到一些问题。

所以这就是我所在的地方:打扰一下我的头撞砖墙的实际代码的状态:)

所有者/服务器创build空间 – 很好

客户来了,发送报价(收到的报价,但客户端断开WebSocket)

服务器/所有者收到报价,但试图发送回答 – 因为客户端断开连接没有发送回….

https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/WsCamEndpoint.groovy#L72

这是websocket发送到parsing操作的扩展类的地方:

https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/ChatUtils.groovy#L244

呼叫:

https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/ChatUtils.groovy#L570

https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/ChatUtils.groovy#L598

https://github.com/vahidhedayati/playground/blob/master/grails-wschat-plugin/src/groovy/grails/plugin/wschat/ChatUtils.groovy#L575

private void jsonmessageUser(Session userSession,String msg) { userSession.getBasicRemote().sendText(msg as String) } private void jsonmessageOther(Session userSession,String msg) { Iterator<Session> iterator=camsessions?.iterator() if (iterator) { while (iterator?.hasNext()) { def crec=iterator?.next() if (crec.isOpen()) { def cuser=crec.getUserProperties().get("camuser").toString() def cmuser=crec.getUserProperties().get("camusername").toString() println "OM ACTIVE USER : ------- ${cuser}" if (!cuser.toString().endsWith(cmuser)) { println "----OTHER ||| ${cmuser} :: ${msg}" crec.getBasicRemote().sendText(msg as String) } } } } } private void jsonmessageOwner(Session userSession,String msg) { Iterator<Session> iterator=camsessions?.iterator() if (iterator) { while (iterator?.hasNext()) { def crec=iterator?.next() if (crec.isOpen()) { def cuser=crec.getUserProperties().get("camuser").toString() def cmuser=crec.getUserProperties().get("camusername").toString() if (cuser.toString().endsWith(cmuser)) { println "----OWNER ||| ${cuser} :: ${msg}" crec.getBasicRemote().sendText(msg as String) } } } } } 

现在这是浏览器上发生的事情:

—服务器:

首先在服务器上我们loginlocal.ip和remote.ip可以说192.168.1.6所以客户端和服务器都击中这个相同的IP,以确保它的所有部分相同的连接

HTTP://local.ip.address:8080 / testwschat / wsChat /

这给了我们一个聊天用户,我们以上面的fflogin

然后手动访问webrtc发件人

HTTP://local.ip.address:8080 / testwschat / wsChat / webrtcsend用户= FF

 webkit client.js?compile=false:305 Thu Oct 02 2014 16:48:23 GMT+0100 (BST) Connection successfully established client.js?compile=false:220 offer received, answer will be created client.js?compile=false:255 Object {sdp: "v=0 ↵o=- 5155933685262328996 2 IN IP4 127.0.0.1 ↵s…5748 label:c32aa4ec-9238-4045-b791-0a94ba741b41 ↵", type: "offer"} client.js?compile=false:62 stream added client.js?compile=false:168 2icecandidate send to room ff client.js?compile=false:177 Thu Oct 02 2014 16:48:38 GMT+0100 (BST) Connection was closed client.js?compile=false:231 icecandidate send to room ff client.js?compile=false:177 WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28 icecandidate send to room ff client.js?compile=false:177 WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28 icecandidate send to room ff client.js?compile=false:177 WebSocket is already in CLOSING or CLOSED state. 

—在客户端:

首先在服务器上,我们login到http://remote.ip.address:8080 / testwschat / wsChat /

这给了我们一个聊天用户,我们以上面的cclogin

然后手动访问webrtc接收器

HTTP://remote.ip.address:8080 / testwschat / wsChat / webrtcrec用户= FF

 sending offer to: ff client.js?compile=false:138 Sending 2 client.js?compile=false:38 4icecandidate send to room ff client.js?compile=false:124 Thu Oct 02 2014 16:48:38 GMT+0100 (BST) Connection was closed client.js?compile=false:231 icecandidate send to room ff client.js?compile=false:124 WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28 icecandidate send to room ff client.js?compile=false:124 WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28 icecandidate send to room ff client.js?compile=false:124 WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28 icecandidate send to room ff client.js?compile=false:124 WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28 icecandidate send to room ff client.js?compile=false:124 WebSocket is already in CLOSING or CLOSED state. client.js?compile=false:28 

在上面的套接字代码中,根据printlns的实际后端websocket日志可以在这里看到:

https://gist.github.com/vahidhedayati/6dbd74a1c4a87d373c05

这次通过日志logging来控制sendServer的值通过网页,这似乎icecandidate json没有被websocket接收。 因为在后端没有这个日志..也许它的缓冲相关..

https://gist.github.com/vahidhedayati/918b731788118de348d0 – 服务器或所有者浏览器日志

https://gist.github.com/vahidhedayati/a51796f3dcbb14088a31 – 客户端/其他用户浏览器日志。

那么我认为我最近的调查帮助我回答了我自己的问题,那就是缓冲区大小。

所以,如果你在Java / Groovy编码,并想与webrtc交互。 你可能会遇到这个问题。 解决的办法是增加你的

 session.setMaxTextMessageBufferSize(1000000) 

当用户打开websocket

 @OnOpen public void whenOpening(Session userSession,EndpointConfig c,@PathParam("user") String user,@PathParam("viewer") String viewer) { if (loggedIn(user)) { userSession.setMaxBinaryMessageBufferSize(1024*512) userSession.setMaxTextMessageBufferSize(1000000) //userSession.setmaxMessageSize(-1L) if (viewer.equals(user)) { userSession.getUserProperties().put("camuser", user+":"+user); }else{ userSession.getUserProperties().put("camuser", user+":"+viewer); } if (!camLoggedIn(user)) { userSession.getUserProperties().put("camusername", user); camsessions.add(userSession) } }else{ log.info "could not find chat user ! ${user}" } }