Я реализовал приложение Conference с WEBRTC и SignalR в качестве сервера сигнализации.
В моей локальной сети все работает нормально, но в Интернете он не может передавать данные.
После многихПоиски, которые я обнаружил, происходят из-за отсутствия ICE и сервера STUN (в моем локальном WebRtc работает с моим частным IP, но в Интернете ему нужен Public IP, который может обрабатываться STUN и ICE).После этого я добавляю ice следующим образом:
function _createConnection() {
console.log('creating RTCPeerConnection...');
//Define Ice Server
var ice = {"iceServers": [
{"url": "stun:numb.viagenie.ca:3478"} //{"url": "stun:stun.l.google.com:19302"}
,{"url": "turn:numb.viagenie.ca", "username": "m_mramezani", "credential": "*******"}
]};
// Create a new PeerConnection
var connection = new RTCPeerConnection(ice); // null = no ICE servers
// A new ICE candidate was found
connection.onicecandidate = function (event) {
if (event.candidate) {
// Let's send it to our peer via SignalR
var message = ChatMessageInput.value;
}
function SendSDPToDoctorAfterDoctorAccept(){
var userConnectionID = document.getElementById("CallerConnectionId").value;
var doctorConnectionID = document.getElementById("DoctorChatID").value;
console.log("Conn started");
_myConnection = _myConnection || _createConnection(null);
console.log(_myConnection +" " +"test");
// Add our stream to the peer connection
_myConnection.addStream(_myMediaStream);
// Create an offer to send our peer
_myConnection.createOffer(function (desc) {
// Set the generated SDP to be our local session description
_myConnection.setLocalDescription(desc, function () {
// And send it to our peer, where it will become their RemoteDescription
//Changed By Ramezani
//var peopleId = localStorage.getItem('peopleId');
var DoctorpeopleId = document.getElementById("DoctorFamilyID").value;
console.log(DoctorpeopleId);
//console.log(doctorChatID);
//m.porniazi code -----------------------------
if (localStorage.getItem('peopleId') == null ) {
alert('session is not founded by anyone');
return;
}
//sessionStorage.setItem('PeopleId', '151185');
//m.porniazi code -----------------------------
console.log(desc);
console.log("sdp "+JSON.stringify({ "sdp": desc }));
console.log("14799");
console.log("CallerChatID: " + userConnectionID);
console.log("DoctorChatID: " + doctorConnectionID);
connectionSR.invoke("SignalingMessage", doctorConnectionID, userConnectionID, DoctorpeopleId, JSON.stringify({ "sdp": desc })).catch(function (err) {
return console.log(err.toString());
});
//hub.server.send(JSON.stringify({ "sdp": desc }));
});
}, function (error) { console.log('Error creating session description: ' + error); });
document.getElementById('startBtn').disabled = true;
document.getElementById('hangUpBtn').disabled = false;
}
Но он работает в интернете, а также когда я проверяю его на chrome: // webrtc-internals / Я не смог найти свойобщедоступный IP-адрес в Интернете, он просто содержит мой частный IP-адрес, в чем моя ошибка?