Retransmission timeout when calling using sipjs

Hi there

I’m a complete newbie to both sip and Asterisk. I’m trying to set up a proof of concept for video/audio calls between two webpages, using Asterisk 13.8-cert4 and sipjs but I keep getting “Retransmission timeout reached on transmission” in the Asterisk logs.

I’ve followed the guide on the website http://sipjs.com/guides/ but the call seems to just time-out and not connect.

Webpage Bob

This page has a button that runs the following function to log in to Asterisk as Bob:

function login(){
var configuration = {
    uri: 'bob@192.168.0.186',
    ws_servers: 'ws://192.168.0.186:8088/ws',
    authorizationUser: 'bob',
    password: 'pwd_bob',
    hackIpInContact: true,
    hackWssInTransport: true,
    traceSip: true
};

var userAgent = new SIP.UA(configuration);
window.userAgent = userAgent
userAgent.on('invite', function (session) {
    session.accept({
        media: {
            render: {
                remote: document.getElementById('remoteVideo'),
                local: document.getElementById('localVideo')
            }
        }
    });
});
}

When this is run Asterisk logs “registered SIP bob at 192.168.0.186”

Webpage Ben

At the other end, I have a button on a webpage calling the following function:

function callExtension() {
    
var session;

var endButton = document.getElementById('endCall');
    endButton.addEventListener("click", function () {
    document.getElementById("message").innerHTML = "End call";
    session.bye();
    alert("Call Ended");
}, false);

var config = {
  
  uri: 'ben@192.168.0.186',

  ws_servers: 'ws://192.168.0.186:8088/ws',

  authorizationUser: 'ben',

  password: 'pwd_ben',
  hackIpInContact: true,
  hackWssInTransport: true,
  traceSip: true

};

var ua = new SIP.UA(config);

ua.invite('sip:ben@192.168.0.186',{
  media: {
    constraints: {
      audio: true,
      video: true
    }
  }
});

var userAgent = new SIP.UA(config);
window.userAgent = userAgent

var options = {
    media: {
        constraints: {
            audio: true,
            video: true
        },
        render: {
            remote: document.getElementById('remoteVideo'),
            local: document.getElementById('localVideo')
        }
    }
};
session = userAgent.invite('sip:bob@192.168.0.186', options);        
} 

At this point I’d expect a video call start between the two pages, or a “permission to use camera and microphone” alert to pop-up on Bob’s chrome. Nothing seems to happen though. Asterisk gives the following output:

Asterisk output:

  == WebSocket connection from '192.168.0.173:48576' for protocol 'sip' accepted using version '13'
    -- Registered SIP 'bob' at 192.168.0.173:48576
  == WebSocket connection from '192.168.0.170:58636' for protocol 'sip' accepted using version '13'
  == WebSocket connection from '192.168.0.170:58637' for protocol 'sip' accepted using version '13'
    -- Registered SIP 'ben' at 192.168.0.170:58636
    -- Registered SIP 'ben' at 192.168.0.170:58637
  == Using SIP RTP CoS mark 5
    -- Executing [ben@from-internal:1] Dial("SIP/ben-00000000", "SIP/ben") in new stack
  == Using SIP RTP CoS mark 5
    -- Executing [bob@from-internal:1] Dial("SIP/ben-00000001", "SIP/bob") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/ben
  == Using SIP RTP CoS mark 5
    -- Called SIP/bob
[Jan 10 16:53:11] WARNING[13321]: chan_sip.c:4060 retrans_pkt: Retransmission timeout reached on transmission 5fc621d2517960962af96b926da37a22@192.168.0.186:5060 for seqno 102 (Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 32000ms with no response
[Jan 10 16:53:11] WARNING[13321]: chan_sip.c:4084 retrans_pkt: Hanging up call 5fc621d2517960962af96b926da37a22@192.168.0.186:5060 - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [ben@from-internal:2] Hangup("SIP/ben-00000000", "") in new stack
  == Spawn extension (from-internal, ben, 2) exited non-zero on 'SIP/ben-00000000'
[Jan 10 16:53:11] WARNING[13321]: chan_sip.c:4060 retrans_pkt: Retransmission timeout reached on transmission 26d276327367fae23c11dba9758bfc08@192.168.0.186:5060 for seqno 102 (Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 32000ms with no response
[Jan 10 16:53:11] WARNING[13321]: chan_sip.c:4084 retrans_pkt: Hanging up call 26d276327367fae23c11dba9758bfc08@192.168.0.186:5060 - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [bob@from-internal:2] Hangup("SIP/ben-00000001", "") in new stack
  == Spawn extension (from-internal, bob, 2) exited non-zero on 'SIP/ben-00000001'

For brevity I’ve added Gist links to two browser outputs and the Asterisk log with sip debug on, in case they are helpful:

Bob browser output
Ben browser output
Asterisk Log with sip debug on

Here are the excerpts from the conf files:

extensions.conf

[from-internal]
exten => bob,1,Dial(SIP/bob)
same => n,Hangup()
exten => ben,1,Dial(SIP/ben)
same => n,Hangup()

sip.conf

[ben]
type=friend
username=ben
secret=pwd_ben
host=dynamic
encryption=yes
avpf=yes 
icesupport=yes
context=from-internal 
directmedia=no 
transport=udp,ws 
force_avp=yes 
dtlsenable=yes 
dtlsverify=no 
dtlscertfile=/etc/asterisk/keys/asterisk.pem
dtlsprivatekey=/etc/asterisk/keys/asterisk.pem 
dtlssetup=actpass

[bob]
type=friend
username=bob
secret=pwd_bob
host=dynamic
context=from-internal
transport=udp,ws

From looking at the browser logs, it looks like Bob never receives the INVITE, which seems to retransmit to some nonexistent place before timing out. Since I’ve registered both users with a sipjs UserAgent, I’m not sure why a connection can’t be established.

Is there any obvious mistake I’m making here? I feel like I’ve made some kind of beginners error, because it shouldn’t be too difficult to get his working, but I’m not sure what area to look in to in order to get this to function.

Any help or general pointers is hugely appreciated.

Many thanks
Ben

Check your NAT settings, if ports(webrtc and sip) are opened in server and PCs and finally don’t use WS use WSS