SIP.js
SIP.js copied to clipboard
FreePABX Configuration every time resulting in a 401 Forbiden.
My Configuration:
const config = {
password : "*****",
displayName : "1003",
uri : 'sip:[email protected]',
wsServers : 'ws://192.168.73.142:8088/ws/',
registerExpires : 30,
traceSip : true,
}
const sipCon = new SIP.UA(config);
//sipCon.debug.enable('JsSIP:*');
//sipCon.debug.enable('JsSIP:*');
sipCon.on('connected', function(e) {
console.log("Connected");
});
sipCon.on('disconnected', function(e) {
console.log("Disconnected");
});
sipCon.on('registered', function(e) {
console.log("Ready");
// Get the userMedia and cache the stream
if (SIP.WebRTC.isSupported()) {
SIP.WebRTC.getUserMedia({ audio : true, video : false }, ctxSip.getUserMediaSuccess, ctxSip.getUserMediaFailure);
}
});
sipCon.on('registrationFailed', function(e) {
console.log(e);
console.log(true, 'Registration Error.', 'An Error occurred registering your phone. Check your settings.');
console.log("Error: Registration Failed");
});
sipCon.on('unregistered', function(e) {
console.log(e);
console.log(true, 'Registration Error.', 'An Error occurred registering your phone. Check your settings.');
console.log("Error: Registration Failed");
});
sipCon.on('invite', function (incomingSession) {
console.log("Error: Invite");
});
Always I received registration error.
Terminal log:
Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | configuration parameters after validation:
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · viaHost: "qg1bsbearbbj.invalid"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · uri: sip:[email protected]
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · wsServers: [{"ws_uri":"ws://192.168.73.142:8088/ws/","sip_uri":"<sip:192.168.73.142:8088;transport=ws;lr>","weight":0,"status":0,"scheme":"WS"}]
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · custom: {}
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · displayName: "1003"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · password: NOT SHOWN
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · registerExpires: 30
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · register: true
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · registrarServer: sip:192.168.73.142
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · wsServerMaxReconnection: 3
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · wsServerReconnectionTimeout: 4
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · connectionRecoveryMinInterval: 2
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · connectionRecoveryMaxInterval: 30
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · keepAliveInterval: 0
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · extraSupported: []
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · usePreloadedRoute: false
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · userAgentString: "SIP.js/0.7.8"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · iceCheckingTimeout: 5000
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · noAnswerTimeout: 60000
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · stunServers: ["stun:stun.l.google.com:19302"]
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · turnServers: []
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · traceSip: true
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · hackViaTcp: false
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · hackIpInContact: false
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · hackWssInTransport: false
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · hackAllowUnregisteredOptionTags: false
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · hackCleanJitsiSdpImageattr: false
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · hackStripTcp: false
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · contactTransport: "ws"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · forceRport: false
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · autostart: true
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · autostop: true
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · rel100: "none"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · replaces: "none"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · mediaHandlerFactory: function(a,c){return new b(a,c)}
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · authenticationFactory: undefined
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · allowLegacyNotifications: false
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · instanceId: "64635eb0-e1fe-4120-a426-78e772cb1b01"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · sipjsId: "mvkhb"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · hostportParams: "192.168.73.142"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · authorizationUser: "1003"
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | · media: undefined
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | user requested startup...
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.transport | connecting to WebSocket ws://192.168.73.142:8088/ws/
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.transport | WebSocket ws://192.168.73.142:8088/ws/ connected
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.ua | connection state set to 0
indexv2.html:60 Connected
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.transport | sending WebSocket message:
REGISTER sip:192.168.73.142 SIP/2.0
Via: SIP/2.0/WS qg1bsbearbbj.invalid;branch=z9hG4bK1037052
Max-Forwards: 70
To: "1003" <sip:[email protected]>
From: "1003" <sip:[email protected]>;tag=9kuolst39e
Call-ID: a266pp2du9thbbe6tk68em
CSeq: 81 REGISTER
Contact: <sip:[email protected];transport=ws>;reg-id=1;+sip.instance="<urn:uuid:64635eb0-e1fe-4120-a426-78e772cb1b01>";expires=30
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: path, gruu, outbound
User-Agent: SIP.js/0.7.8
Content-Length: 0
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.transport | received WebSocket text message:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WS qg1bsbearbbj.invalid;branch=z9hG4bK1037052;received=192.168.100.235;rport=53117
From: "1003" <sip:[email protected]>;tag=9kuolst39e
To: "1003" <sip:[email protected]>;tag=as7745a9dc
Call-ID: a266pp2du9thbbe6tk68em
CSeq: 81 REGISTER
Server: FPBX-15.0.37.4(16.13.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="0c490a32"
Content-Length: 0
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.transport | sending WebSocket message:
REGISTER sip:192.168.73.142 SIP/2.0
Via: SIP/2.0/WS qg1bsbearbbj.invalid;branch=z9hG4bK8792059
Max-Forwards: 70
To: "1003" <sip:[email protected]>
From: "1003" <sip:[email protected]>;tag=9kuolst39e
Call-ID: a266pp2du9thbbe6tk68em
CSeq: 82 REGISTER
Authorization: Digest algorithm=MD5, username="1003", realm="asterisk", nonce="0c490a32", uri="sip:192.168.73.142", response="e4b690780a533e30d0772066a45a03e9"
Contact: <sip:[email protected];transport=ws>;reg-id=1;+sip.instance="<urn:uuid:64635eb0-e1fe-4120-a426-78e772cb1b01>";expires=30
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: path, gruu, outbound
User-Agent: SIP.js/0.7.8
Content-Length: 0
indexv2.html:36 Thu Jan 25 2024 11:48:33 GMT-0400 (Horário Padrão do Amazonas) | sip.transport | received WebSocket text message:
SIP/2.0 403 Forbidden
Via: SIP/2.0/WS qg1bsbearbbj.invalid;branch=z9hG4bK8792059;received=192.168.100.235;rport=53117
From: "1003" <sip:[email protected]>;tag=9kuolst39e
To: "1003" <sip:[email protected]>;tag=as7745a9dc
Call-ID: a266pp2du9thbbe6tk68em
CSeq: 82 REGISTER
Server: FPBX-15.0.37.4(16.13.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0
indexv2.html:77 f {logger: b, headers: {…}, status_code: 403, reason_phrase: 'Forbidden', data: 'SIP/2.0 403 Forbidden\r\nVia: SIP/2.0/WS qg1bsbearbb…Supported: replaces, timer\r\nContent-Length: 0\r\n\r\n', …}
indexv2.html:78 true 'Registration Error.' 'An Error occurred registering your phone. Check your settings.'
indexv2.html:79 Error: Registration Failed
Every time I see the "Worng Password" log.
May you help me?
This failure arises because WebRTC uses the legacy chan_sip. You must switch to the chan_pjsip instead.