无法设置本地应答 sdp:在错误状态下调用:STATE_INPROGRESS
Failed to set local answer sdp: Called in wrong state: STATE_INPROGRESS
我有两个客户:
1) Chrome(版本 50.0.2661.102 m)在 Windows 7 PC
2) Chrome(版本 50.0.2661.89)在 Android 平板电脑上
两者都在同一网络中(因此不需要 STUN/TURN 服务器)。
我在装有 Centos 6 的 VirtualBox 虚拟机上使用 node.js (webSocket) 构建的自己的信号服务器。
客户端与 video/sound 的通信正常。现在我想将文件从一个客户端传输到另一个客户端。作为我的代码的基础,我使用这个例子的代码
here
正如这段代码所建议的,我在创建 PeerConnection 之后创建了 dataChannnel。
function createPeerConnection() {
....
myPeerConnection = new RTCPeerConnection(iceServers, optional);
myDataChannel = myPeerConnection.createDataChannel('myDataChannel');
// Set up event handlers for the ICE negotiation process.
myPeerConnection.onicecandidate = handleICECandidateEvent;
myPeerConnection.onaddstream = handleAddStreamEvent;
myPeerConnection.onnremovestream = handleRemoveStreamEvent;
myPeerConnection.oniceconnectionstatechange = handleICEConnectionStateChangeEvent;
myPeerConnection.onicegatheringstatechange = handleICEGatheringStateChangeEvent;
myPeerConnection.onsignalingstatechange = handleSignalingStateChangeEvent;
myPeerConnection.onnegotiationneeded = handleNegotiationNeededEvent;
myPeerConnection.ondatachannel = handleDataChannel;
myDataChannel.onmessage = handleDataChannelMessage;
myDataChannel.onopen = handleDataChannelOpen;
}
...
...
function invite(peerId) {
...
createPeerConnection();
...
}
...
...
function handleVideoOfferMsg(msg) {
thereIsNegotiation = true;
targetUsername = msg.name;
// Call createPeerConnection() to create the RTCPeerConnection.
log("Starting to accept invitation from " + targetUsername);
createPeerConnection();
// We need to set the remote description to the received SDP offer
// so that our local WebRTC layer knows how to talk to the caller.
var desc = new RTCSessionDescription(msg.sdp);
myPeerConnection.setRemoteDescription(desc)
.then(function(stream) {
log("-- Calling myPeerConnection.addStream()");
return myPeerConnection.addStream(localStream);
})
.then(function() {
log("------> Creating answer");
// Now that we've successfully set the remote description, we need to
// start our stream up locally then create an SDP answer. This SDP
// data describes the local end of our call, including the codec
// information, options agreed upon, and so forth.
return myPeerConnection.createAnswer();
})
.then(function(answer) {
log("------> Setting local description after creating answer");
// We now have our answer, so establish that as the local description.
// This actually configures our end of the call to match the settings
// specified in the SDP.
return myPeerConnection.setLocalDescription(answer);
})
.then(function() {
var msg = {
name: clientId,
room: roomId,
target: targetUsername,
type: "video-answer",
sdp: myPeerConnection.localDescription
};
// We've configured our end of the call now. Time to send our
// answer back to the caller so they know that we want to talk
// and how to talk to us.
log("Sending answer packet back to other peer");
sendToServer(msg);
})
.catch(handleGetUserMediaError);
}
当第二个客户提出报价时,第一个客户试图做出回答,我收到错误
打开摄像头和/或麦克风时出错:无法设置本地应答
spd: Failed to push down transport 描述: 提供本地指纹
但没有可用的身份。
或
打开摄像头和/或麦克风时出错:无法设置本地应答
spd:在错误状态下调用:STATE_INPROGRESS
只有1次创建成功
我必须在其他地方创建 DataChannel 吗?喜欢这里:
function handleICEConnectionStateChangeEvent {
switch(myPeerConnection.iceConnectionState) {
...
case "connected":
createDataChannel();
break;
}
}
function createDataChannel(){
myDataChannel = myPeerConnection.createDataChannel('myDataChannel');
myPeerConnection.ondatachannel = handleDataChannel;
myDataChannel.onmessage = handleDataChannelMessage;
myDataChannel.onopen = handleDataChannelOpen;
}
有什么建议吗?
此代码中的错误是发送方和接收方都创建了新的数据通道。正确的是,创建数据通道
myDataChannel = myPeerConnection.createDataChannel('myDataChannel')
另一个等待数据通道的创建:
myPeerConnection.ondatachannel = handleDataChannel;
我有两个客户:
1) Chrome(版本 50.0.2661.102 m)在 Windows 7 PC
2) Chrome(版本 50.0.2661.89)在 Android 平板电脑上
两者都在同一网络中(因此不需要 STUN/TURN 服务器)。
我在装有 Centos 6 的 VirtualBox 虚拟机上使用 node.js (webSocket) 构建的自己的信号服务器。
客户端与 video/sound 的通信正常。现在我想将文件从一个客户端传输到另一个客户端。作为我的代码的基础,我使用这个例子的代码 here
正如这段代码所建议的,我在创建 PeerConnection 之后创建了 dataChannnel。
function createPeerConnection() {
....
myPeerConnection = new RTCPeerConnection(iceServers, optional);
myDataChannel = myPeerConnection.createDataChannel('myDataChannel');
// Set up event handlers for the ICE negotiation process.
myPeerConnection.onicecandidate = handleICECandidateEvent;
myPeerConnection.onaddstream = handleAddStreamEvent;
myPeerConnection.onnremovestream = handleRemoveStreamEvent;
myPeerConnection.oniceconnectionstatechange = handleICEConnectionStateChangeEvent;
myPeerConnection.onicegatheringstatechange = handleICEGatheringStateChangeEvent;
myPeerConnection.onsignalingstatechange = handleSignalingStateChangeEvent;
myPeerConnection.onnegotiationneeded = handleNegotiationNeededEvent;
myPeerConnection.ondatachannel = handleDataChannel;
myDataChannel.onmessage = handleDataChannelMessage;
myDataChannel.onopen = handleDataChannelOpen;
}
...
...
function invite(peerId) {
...
createPeerConnection();
...
}
...
...
function handleVideoOfferMsg(msg) {
thereIsNegotiation = true;
targetUsername = msg.name;
// Call createPeerConnection() to create the RTCPeerConnection.
log("Starting to accept invitation from " + targetUsername);
createPeerConnection();
// We need to set the remote description to the received SDP offer
// so that our local WebRTC layer knows how to talk to the caller.
var desc = new RTCSessionDescription(msg.sdp);
myPeerConnection.setRemoteDescription(desc)
.then(function(stream) {
log("-- Calling myPeerConnection.addStream()");
return myPeerConnection.addStream(localStream);
})
.then(function() {
log("------> Creating answer");
// Now that we've successfully set the remote description, we need to
// start our stream up locally then create an SDP answer. This SDP
// data describes the local end of our call, including the codec
// information, options agreed upon, and so forth.
return myPeerConnection.createAnswer();
})
.then(function(answer) {
log("------> Setting local description after creating answer");
// We now have our answer, so establish that as the local description.
// This actually configures our end of the call to match the settings
// specified in the SDP.
return myPeerConnection.setLocalDescription(answer);
})
.then(function() {
var msg = {
name: clientId,
room: roomId,
target: targetUsername,
type: "video-answer",
sdp: myPeerConnection.localDescription
};
// We've configured our end of the call now. Time to send our
// answer back to the caller so they know that we want to talk
// and how to talk to us.
log("Sending answer packet back to other peer");
sendToServer(msg);
})
.catch(handleGetUserMediaError);
}
当第二个客户提出报价时,第一个客户试图做出回答,我收到错误
打开摄像头和/或麦克风时出错:无法设置本地应答 spd: Failed to push down transport 描述: 提供本地指纹 但没有可用的身份。
或
打开摄像头和/或麦克风时出错:无法设置本地应答 spd:在错误状态下调用:STATE_INPROGRESS
只有1次创建成功
我必须在其他地方创建 DataChannel 吗?喜欢这里:
function handleICEConnectionStateChangeEvent {
switch(myPeerConnection.iceConnectionState) {
...
case "connected":
createDataChannel();
break;
}
}
function createDataChannel(){
myDataChannel = myPeerConnection.createDataChannel('myDataChannel');
myPeerConnection.ondatachannel = handleDataChannel;
myDataChannel.onmessage = handleDataChannelMessage;
myDataChannel.onopen = handleDataChannelOpen;
}
有什么建议吗?
此代码中的错误是发送方和接收方都创建了新的数据通道。正确的是,创建数据通道
myDataChannel = myPeerConnection.createDataChannel('myDataChannel')
另一个等待数据通道的创建:
myPeerConnection.ondatachannel = handleDataChannel;