想知道是否有人对我在这里做错了什么有任何想法:
该指南的解释非常好,我已经通过nodejs进行了测试,并且一切正常。
我现在正尝试将示例移植到groovy中。在grails插件中并遇到一些问题。
所以这就是我所处的位置:原谅实际代码的状态让我在砖墙上碰了一会儿:)
所有者/服务器创建空间 - 精细
客户端出现并发送报价(收到报价但客户断开连接的websocket)
服务器/所有者收到要约,但在尝试发送回答时 - 由于客户端已断开连接,因此无法发回任何内容....
这是websocket发送到解析操作的扩展类的地方:
呼叫:
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)
}
}
}
}
}
现在这是浏览器上发生的事情:
---服务器:
首先在服务器上我们登录到local.ip和remote.ip就是192.168.1.6,所以在客户端和服务器上点击这个相同的ip以确保它的所有部分都是相同的连接
http://local.ip.address:8080/testwschat/wsChat/
这为我们提供了一个我们以上面的ff登录的聊天用户
然后手动访问webrtc发件人
http://local.ip.address:8080/testwschat/wsChat/webrtcsend?user=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.
---在客户端:
首先在服务器上登录 http://remote.ip.address:8080/testwschat/wsChat/
这为我们提供了一个我们以上面的cc登录的聊天用户
然后手动访问webrtc接收器
http://remote.ip.address:8080/testwschat/wsChat/webrtcrec?user=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
这次通过登录到通过网页控制sendServer值来记录更多日志,似乎websocket没有收到icecandidate json。因为在后端没有这个日志..也许它的缓冲区相关..https://gist.github.com/vahidhedayati/918b731788118de348d0 - 服务器或所有者浏览器日志
https://gist.github.com/vahidhedayati/a51796f3dcbb14088a31 - 客户端/其他用户浏览器日志。
答案 0 :(得分:1)
好吧,伙计们,我认为我的上一次调查帮助我回答了我自己的问题,那就是缓冲区大小。
因此,如果您使用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}"
}
}