Hello, there!
I'm working with peer to peer connection. Before, I used ws://ovh36.antmedia.io:5080/LiveApp/websocket this URL as a webSocket URL. In that time all worked fine. But now, I've switched the webSocket URL to my local ams server URL. And now the join() method is not calling. Please help me, it's urgent for me.
Here is my code bellow:
<html><head><title>Ant Media Server WebRTC Peer</title><metaname="viewport"content="width=device-width, initial-scale=1"/><metacharset="UTF-8"/><scriptsrc="https://webrtc.github.io/adapter/adapter-latest.js"></script></head><body><divclass="container"style="padding:40px15px;text-align: center"><videoid="localVideo"autoplaymutedcontrolsplaysinlinewidth="480"></video><videoid="remoteVideo"autoplaycontrolsplaysinlinewidth="480"></video><br/><br/><divclass="input-group offset-sm-2 col-sm-8"><inputtype="text"class="form-control"value="stream1"id="streamName"placeholder="Type stream name"/><spanclass="input-group-btn"><buttonclass="btn btn-primary"disabledid="join_button">
Join
</button><buttonclass="btn btn-primary"disabledid="leave_button">
Leave
</button></span></div><divstyle="padding:10px"><buttonclass="btn btn-outline-primary"id="turn_off_camera">
Turn off Camera
</button><buttonclass="btn btn-outline-primary"id="turn_on_camera">
Turn on Camera
</button><buttonclass="btn btn-outline-primary"id="mute_mic">
Mute Local Mic
</button><buttonclass="btn btn-outline-primary"id="unmute_mic">
Unmute Local Mic
</button></div></div><script></script></body><scripttype="module">import{WebRTCAdaptor} from "./js/webrtc_adaptor.js";var join_button = document.getElementById("join_button");
join_button.addEventListener("click", join,false);var leave_button = document.getElementById("leave_button");
leave_button.addEventListener("click", leave,false);var turn_on_camera = document.getElementById("turn_on_camera");
turn_on_camera.addEventListener("click", turnOnLocalCamera,false);var turn_off_camera = document.getElementById("turn_off_camera");
turn_off_camera.addEventListener("click", turnOffLocalCamera,false);var mute_mic = document.getElementById("mute_mic");
mute_mic.addEventListener("click", muteLocalMic,false);var unmute_mic = document.getElementById("unmute_mic");
unmute_mic.addEventListener("click", unmuteLocalMic,false);var streamNameBox = document.getElementById("streamName");function join(){
webRTCAdaptor.join(streamNameBox.value);}function leave(){
webRTCAdaptor.leave(streamNameBox.value);}function turnOffLocalCamera(){
webRTCAdaptor.turnOffLocalCamera(streamNameBox.value);}function turnOnLocalCamera(){
webRTCAdaptor.turnOnLocalCamera(streamNameBox.value);}function muteLocalMic(){
webRTCAdaptor.muteLocalMic(streamNameBox.value);}function unmuteLocalMic(){
webRTCAdaptor.unmuteLocalMic(streamNameBox.value);}var pc_config ={
iceServers:[{
urls:"stun:stun1.l.google.com:19302",},],};var sdpConstraints ={OfferToReceiveAudio:true,OfferToReceiveVideo:true,};var mediaConstraints ={
video:true,
audio:true,};var appName = location.pathname.substring(0,
location.pathname.lastIndexOf("/")+1);var websocketURL ="ws://127.0.0.1:5080/LiveApp/websocket";if(location.protocol.startsWith("https")){
websocketURL ="wss://"+ location.hostname +":5443"+ appName +"websocket";}var webRTCAdaptor =newWebRTCAdaptor({
websocket_url: websocketURL,
mediaConstraints: mediaConstraints,
peerconnection_config: pc_config,
sdp_constraints: sdpConstraints,
localVideoId:"localVideo",
remoteVideoId:"remoteVideo",
callback:function(info){if(info =="initialized"){
console.log("initialized");
join_button.disabled =false;
leave_button.disabled =true;}elseif(info =="joined"){//joined the stream
console.log("joined");
join_button.disabled =true;
leave_button.disabled =false;}elseif(info =="leaved"){//leaved the stream
console.log("leaved");
join_button.disabled =false;
leave_button.disabled =true;}},
callbackError:function(error){//some of the possible errors, NotFoundError, SecurityError,PermissionDeniedError
console.log("error callback: "+ error);
alert(error);},});</script></html>
Note: I run this code with live server. Added that, ws://ovh36.antmedia.io:5080/LiveApp/websocket this URL is now not working. Using this URL I get 'webSocket not connected' error.
Question
Tahmid Khandokar
Hello, there!
I'm working with peer to peer connection. Before, I used ws://ovh36.antmedia.io:5080/LiveApp/websocket this URL as a webSocket URL. In that time all worked fine. But now, I've switched the webSocket URL to my local ams server URL. And now the join() method is not calling. Please help me, it's urgent for me.
Here is my code bellow:
Note: I run this code with live server. Added that, ws://ovh36.antmedia.io:5080/LiveApp/websocket this URL is now not working. Using this URL I get 'webSocket not connected' error.
Edited by Tahmid Khandokarsomething I've missed
Link to comment
Share on other sites
Top Posters For This Question
1
1
Popular Days
Oct 13
2
Top Posters For This Question
mustafaboleken 1 post
Tahmid Khandokar 1 post
Popular Days
Oct 13 2022
2 posts
1 answer to this question
Recommended Posts