Forwarding register to another server

Hello everyone,

I am trying to forward SIP requests received from Asterisk to another SIP server. I am doing this specifically because I am trying to keep track of user registrations on this second server.

I just tested the second SIP server with an ordinary SIP client and everything works well: receives register, response 200 OK.

Now: how to forward requests received from Asterisk to the second SIP server?

Thank you for your time!

1 Like

Asterisk is not a SIP proxy, it does not forward requests like this.

Okay, sorry.

Is there any other way to keep track of the users registration? Like Asterisk sending a notification or making a request to another server when a register comes in?

You should use another setup, use Kamailio as a registrar, use the the DMQ_USERLOC module to sync the regs to second Kamailio, route calls from Kamailio to Asterisk… Downside… Have to learn how to work with Kamailio.

Events will be generated on the Asterisk Manager Interface when a device becomes reachable, these events can be used to know when things occur.

So I guess AMI event AgentLogin should do?

https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+ManagerEvent_AgentLogin

No, that is for a call queue agent. An event that may be useful is ContactStatus[1]. The easiest thing would be to just connect to AMI, perform various things, and get a feel for the events.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+ManagerEvent_ContactStatus

1 Like

Ok, perfect! I’ll try, thank you.

Solved, using https://www.npmjs.com/package/asterisk-manager on my Node.js server. I’ll leave my piece of code.

ami.on('peerstatus', (evt) => {
    console.log('AMI Event PeerStatus');
    if (evt.peerstatus === 'Reachable') {
        console.log(evt.peer + ' is now reachable.');
    }
    if (evt.peerstatus === 'Unreachable') {
        console.log(evt.peer + ' is now unreachable.');
    }
});
2 Likes

Just a question, maybe I dont understand, now the other server only knows that a peer is reachable or unreachable, but you dont know how to reach the peer…Or am I in need of a new pair of glasses… :wink:

1 Like