Hello all,
I have a [SIP client] <-> Kamailio <-> Asterisk installation. Sip clients are
both WebRTC and Android app. WebRTC connects via 443 while Android app connects VIA TLS at
port 5061. WebRTC client uses jsSIP library. My Kamailio version is 5.5.3 (x86_64/linux)
I had been using asterisk directly to terminate WebRTC clients previously and was using
the qualify feature to periodically send OPTIONS packet to all connected clients as a keep
alive mechanism. This allowed the client to detect any loss of connectivity and reconnect
back to server if there is any loss of connectivity.
After moving to Kamailio I am looking for a similar feature, where Kamailio sends OPTIONS
(or any other packets) periodically to the WebRTC clients. My attempts so far hasn't
been a success.
I am aware of couple of options for keepliave in kamailio:
1. nat_keeplaive()
I have some what naively copied the example from nat_keepalive() documentation into
route[NATDETECT] but that is not working.
route[NATDETECT] {
force_rport();
#!ifdef WITH_WEBSOCKETS
if (nat_uac_test(64)) {
if (is_method("REGISTER")) {
fix_nated_register();
} else {
if (!add_contact_alias()) {
sl_send_reply("400", "Bad Request");
exit;
}
}
setflag(FLT_NATS);
return;
}
#!endif
if (nat_uac_test(19)) {
if (is_method("REGISTER")) {
fix_nated_register();
}
fix_contact();
}
setflag(FLT_NATS);
if ((method=="REGISTER" || method=="SUBSCRIBE" ||
(method=="INVITE" && !has_totag())) &&
client_nat_test("3"))
{
nat_keepalive();
}
return;
}
2. keepalive module
This looks like what I want, but I am not sure how to add a new WebRTC connection to the
list of endpoints for pinging.
This is the handler for xhttp:request, should the ka_add_destination be added here?
event_route[xhttp:request] {
set_reply_close();
set_reply_no_connect();
if ($Rp != MY_WS_PORT
#!ifdef WITH_TLS
&& $Rp != MY_WSS_PORT
#!endif
) {
xlog("L_WARN", "HTTP request received on $Rp\n");
xhttp_reply("403", "Forbidden", "", "");
exit;
}
if ($hdr(Upgrade)=~"websocket" && $hdr(Connection)=~"Upgrade"
&& $rm=~"GET") {
if ($hdr(Host) == $null || !is_myself("sip:" + $hdr(Host))) {
xhttp_reply("403", "Forbidden", "", "");
exit;
}
if (ws_handle_handshake())
{
exit;
}
}
xhttp_reply("404", "Not Found", "", "");
}
My search so far has not returned any other means to send options packets to WebRTC
clients. Been banging my head around this for couple of days, and any help will be much
appreciated.
X.