On 30 Jun 2021, at 09:10, Shahid Hussain <shnx88@gmail.com> wrote:

Hi,
Websocket module documentation has a code reference to use aliases for SIP routing. However, aliases will not work in the following setup and situation.
1. Kamailio is configured with active and standby node
2. Ping is implemented from webclient and kamailio responds with pong.
3. Two clients ClinetA and ClientB registered themselves to Kamailio.
4. After SIP negotiation (INVITE-200OK) each client learnt about below aliases.
Alias of ClientA:
alias=172.27.6.98~58336
Alias of ClientB:
alias=172.27.6.98~58342
 
So normally if ClientB wants to send SIP message to ClientA, SIP URI from ClientB looks like below
ACK sip:v9d0gtl6@q0lrdlj63pik.invalid;alias=172.27.6.98~58336~5;transport=ws SIP/2.0
 4. Call is in a connected state.

Following is the issue.
i.  Switchover (or network lost or reboot) at Kamailio happened
ii.  Due to ping pong both the clients detected network loss individually and re-registered themselves.
iii.  Aliases of both the clients got changed.
New Alias of ClientA:
alias=172.27.6.98~ 58346
 
New Alias of ClientB:
alias=172.27.6.98~ 58348
 
iv.   But ClientB doesn’t know that ClientA also re-registered and ClientA’s alias got changed and vice-versa
v.    Because of this ClientB still sends BYE with Initial alias
BYE sip:v9d0gtl6@q0lrdlj63pik.invalid;alias=172.27.6.98~58336~5;transport=ws SIP/2.0

Would like to know what is the recommended solution for this problem using alias or is it a limitation of using alias?

Full implementation of SIP outbound is the only solution close to solving this problem in the IETF standards.
However, I have seen no single SIP client that have implemented this, even though Kamailio supports
it on the server side. The idea is that you always have two TCP connections to two active servers.

https://datatracker.ietf.org/doc/rfc5626/

Having said that, SIP outbound enables registration survival and always being reachable, but it does not handle dialog survival. It was something we discussed for a while at the latest Kamailio dev meeting.

Hopefully the actual RTP streams can survive the failover and the call can go on, but if it depends on SIP signalling there’s no other way (that i know of) to survive and move the call to a new server with a new TCP connection. I have struggled with similar problems and made possible call survival in the case of lost SIP signalling path. It requires SIP uas that doesn’t implement any keepalive or SIP timer that will hangup if SIP signalling is dead.

/O