I am unable to register to FreeSwitch server & unable to call to SIP client (XLite) by using SIPml5 SIP client.
Following is my HTML5 code:
<!DOCTYPE html>
<html>
<head>
<meta content="charset=utf-8"/>
<script type="text/javascript" src="SIPml-api.js"></script>
<title>SIP Client 1</title>
<script type="text/javascript">
window.onload = function()
{
var readyCallback = function(e){
createSipStack(); // see next section
};
var errorCallback = function(e){
console.error('Failed to initialize the engine: ' + e.message);
}
SIPml.init(readyCallback, errorCallback);
console.info("WINDOW ONLOAD");
}
var sipStack;
function createSipStack()
{
var eventsListener = function(e)
{
if(e.type == 'started')
{
login();
}
else if(e.type == 'i_new_message')
{
acceptMessage(e);
}
else if(e.type == 'i_new_call')
{
acceptCall(e);
}
}
sipStack = new SIPml.Stack(
{
realm: '192.168.1.33', // mandatory: domain name
impi: '1001', // mandatory: authorization name (IMS Private Identity)
impu: 'sip:[email protected]', // mandatory: valid SIP Uri (IMS Public Identity)
password: '1234',
display_name: 'Osama', // optional
enable_rtcweb_breaker: true,
events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events
});
sipStack.start();
console.info("CREATE SIP STACK");
}
var registerSession;
var eventsListener = function(e){
console.info('session event = ' + e.type);
if(e.type == 'connected' && e.session == registerSession){
makeCall();
}
}
function login(){
registerSession = sipStack.newSession('register', {
events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events
});
registerSession.register();
console.info("LOGIN");
}
var callSession;
function makeCall()
{
var eventsListener = function(e)
{
console.info('session event = ' + e.type);
}
callSession = sipStack.newSession('call-audiovideo', {
video_local: document.getElementById('video_local'),
video_remote: document.getElementById('video_remote'),
audio_remote: document.getElementById('audio_remote'),
events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events
});
callSession.call('1002');
console.info("MAKE CALL");
}
function acceptCall(e){
e.newSession.accept(); // e.newSession.reject() to reject the call
}
</script>
</head>
<body>
<form method="post" style="height: 197px">
<input name="Button1" type="button" value="Call" onclick="makeCall()">
<input name="Button2" type="button" value="Accept" onclick="acceptCall"><video class="video" id="video_remote" autoplay="autoplay" style="width: 184px; height: 188px"></video>
<audio id="audio_remote" autoplay="autoplay" />
</audio><video class="video" width="88px" height="72px" id="video_local" autoplay="autoplay"></video><span></span></form>
</body>
</html>
Following is my Chrome console output:
SIPML5 API version = 1.3.203 SIPml-api.js:1
User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 SIPml-api.js:1
WebSocket supported = yes SIPml-api.js:1
Navigator friendly name = chrome SIPml-api.js:1
OS friendly name = windows SIPml-api.js:1
Have WebRTC = yes SIPml-api.js:1
Have GUM = yes SIPml-api.js:1
Engine initialized SIPml-api.js:1
s_websocket_server_url=(null) SIPml-api.js:1
s_sip_outboundproxy_url=(null) SIPml-api.js:1
b_rtcweb_breaker_enabled=yes SIPml-api.js:1
b_click2call_enabled=no SIPml-api.js:1
b_early_ims=yes SIPml-api.js:1
b_enable_media_stream_cache=no SIPml-api.js:1
o_bandwidth={} SIPml-api.js:1
o_video_size={} SIPml-api.js:1
SIP stack start: proxy='ns313841.ovh.net:10062', realm='<sip:192.168.1.33>', impi='1001', impu='"Osama"<sip:[email protected]>' SIPml-api.js:1
Connecting to 'wss://ns313841.ovh.net:10062' SIPml-api.js:1
CREATE SIP STACK default.html:52
WINDOW ONLOAD default.html:21
__tsip_transport_ws_onopen SIPml-api.js:1
State machine: tsip_dialog_register_Started_2_InProgress_X_oRegister SIPml-api.js:1
SEND: REGISTER sip:192.168.1.33 SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKpMrcuIswwvJBNixNUiHLuVPJA7tXxnrN;rport
From: "Osama"<sip:[email protected]>;tag=UAy54NJ9TiBQ4J8hWEn8
To: "Osama"<sip:[email protected]>
Contact: "Osama"<sips:[email protected];rtcweb-breaker=yes;transport=wss>;expires=1800;click2call=no
Call-ID: 690d263e-325b-1fc8-5bf7-bc5a545940f1
CSeq: 2210 REGISTER
Content-Length: 0
Max-Forwards: 70
Supported: path
SIPml-api.js:1
LOGIN default.html:68
session event = connecting default.html:58
session event = sent_request default.html:58
State machine: tsip_dialog_register_Any_2_Terminated_X_transportError SIPml-api.js:1
=== REGISTER Dialog terminated === SIPml-api.js:1
session event = transport_error default.html:58
session event = terminated default.html:58
The FSM is in the final state
I followed this developer guide. I don't know where am going wrong. I even enabled RTCWEB breaker as mentioned here. Please help me in registering to FreeSwitch server & calling to SIP client using SIPml5 client. The XLite is registered to FreeSwitch & is in ready state.
You need to install webrtc2sip in order to work with web client. I also faced the same problem i.e. transport error but after installing webrtc2sip this problem has been resolved. I am able to connect to FreeSwitch successfully although now there are other problems.
to install it Go to this link - http://code.google.com/p/webrtc2sip/wiki/Building_Source_v2_0
it looks lengthy but its straight forward.
Also don' forget to read the technical guide here.
After successfull installation, run this command in terminal
and find the socket address of webrtc2sip server which should look like "192.168.1.2:10060" and put this address in your code in front of websocket address. ws://192.168.1.2:10060 precisely.