Is there an easy way to figure out on which server a uac is registered when using a shared database (modparam("usrloc", "db_mode", 3)).
When uac1 is registered on server1 (dns srv loadbalancing) and uac2 is on server2. A call from uac1 to uac2 with a simple lookup("location") will result in server1 directly trying to connect to uac2. If this device is natted (or behind a stateful firewall) this will fail.
In the location table the column socket contains the server which received the request. So if I know this value I can have server2 route the call to this value/server and have the call delivered to uac1 via an "existing connection".
The idea was to use reg_fetch_contacts to fetch this/these socket values in $ulc and in case they are not local redirect/branch to those servers. But if the value of socket isn't local the $ulc for socket is null.
I could use sqlops to fetch this manually, but is there an easier way I am missing?
On 14 Apr 2015, at 17:06, Daniel Tryba d.tryba@pocos.nl wrote:
Is there an easy way to figure out on which server a uac is registered when using a shared database (modparam("usrloc", "db_mode", 3)).
When uac1 is registered on server1 (dns srv loadbalancing) and uac2 is on server2. A call from uac1 to uac2 with a simple lookup("location") will result in server1 directly trying to connect to uac2. If this device is natted (or behind a stateful firewall) this will fail.
In the location table the column socket contains the server which received the request. So if I know this value I can have server2 route the call to this value/server and have the call delivered to uac1 via an "existing connection".
The idea was to use reg_fetch_contacts to fetch this/these socket values in $ulc and in case they are not local redirect/branch to those servers. But if the value of socket isn't local the $ulc for socket is null.
I could use sqlops to fetch this manually, but is there an easier way I am missing?
Use the path header?
/O
On 14/04/15 17:11, Olle E. Johansson wrote:
On 14 Apr 2015, at 17:06, Daniel Tryba d.tryba@pocos.nl wrote:
Is there an easy way to figure out on which server a uac is registered when using a shared database (modparam("usrloc", "db_mode", 3)).
When uac1 is registered on server1 (dns srv loadbalancing) and uac2 is on server2. A call from uac1 to uac2 with a simple lookup("location") will result in server1 directly trying to connect to uac2. If this device is natted (or behind a stateful firewall) this will fail.
In the location table the column socket contains the server which received the request. So if I know this value I can have server2 route the call to this value/server and have the call delivered to uac1 via an "existing connection".
The idea was to use reg_fetch_contacts to fetch this/these socket values in $ulc and in case they are not local redirect/branch to those servers. But if the value of socket isn't local the $ulc for socket is null.
I could use sqlops to fetch this manually, but is there an easier way I am missing?
Use the path header?
Upcoming major release has some embedded functionality for this case, relying on path -- iirc, was added by Charles Chance:
- http://kamailio.org/docs/modules/4.3.x/modules/registrar.html#registrar.p.pa...
Adding path can be done in config, then apply changes before doing save location for register request.
Cheers, Daniel
On Tuesday 14 April 2015 17:59:01 Daniel-Constantin Mierla wrote:
Upcoming major release has some embedded functionality for this case, relying on path -- iirc, was added by Charles Chance:
Good to know, if this could do something with DNS SRV records to find out if a recieved socket in the location db is in the list for the domain, you'd only have to add a server to DNS to add it to the cluster (idealy).
http://kamailio.org/docs/modules/4.3.x/modules/registrar.html#registrar.p.pa th_check_local
Adding path can be done in config, then apply changes before doing save location for register request.
I figured it out just before your response :)
On 14/04/15 18:40, Daniel Tryba wrote:
On Tuesday 14 April 2015 17:59:01 Daniel-Constantin Mierla wrote:
Upcoming major release has some embedded functionality for this case, relying on path -- iirc, was added by Charles Chance:
Good to know, if this could do something with DNS SRV records to find out if a recieved socket in the location db is in the list for the domain, you'd only have to add a server to DNS to add it to the cluster (idealy).
Not really getting the relation here with location service here, or are you looking at just detecting if the request is coming from another server in the farm?
If yes, then if(src_ip=="mydomain.com") should work and do dns to retrieve the addresses associated with the domain in order to compare with the source ipt.
Cheers, Daniel
http://kamailio.org/docs/modules/4.3.x/modules/registrar.html#registrar.p.pa th_check_local
Adding path can be done in config, then apply changes before doing save location for register request.
I figured it out just before your response :)
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On Tuesday 14 April 2015 17:11:45 Olle E. Johansson wrote:
I could use sqlops to fetch this manually, but is there an easier way I am missing?
Use the path header?
When registering directly to the srv records loadbalanced sip servers there is no path. But forcefully adding it before save() does the trick
if(!is_in_subnet($si, "loadbalancersubnet")) { append_hf("Path: sip:localip:5060;lr\r\n"); msg_apply_changes(); }
if (save("location"))
(maybe better to check for the absence of a path header)
Next problem is getting to the INVITE to the endpoint. server2 is trying to deliver the INVITE to the internal ipadress of uac2.
I hate NAT :(
But thank you Olle for one of your always insightful hints.
Note that you could equally use add_path().
On 14 April 2015 at 13:33, Daniel Tryba d.tryba@pocos.nl wrote:
On Tuesday 14 April 2015 17:11:45 Olle E. Johansson wrote:
I could use sqlops to fetch this manually, but is there an easier way I am missing?
Use the path header?
When registering directly to the srv records loadbalanced sip servers there is no path. But forcefully adding it before save() does the trick
if(!is_in_subnet($si, "loadbalancersubnet")) { append_hf("Path: <sip:localip:5060;lr>\r\n"); msg_apply_changes(); } if (save("location"))
(maybe better to check for the absence of a path header)
Next problem is getting to the INVITE to the endpoint. server2 is trying to deliver the INVITE to the internal ipadress of uac2.
I hate NAT :(
But thank you Olle for one of your always insightful hints.
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On Tuesday 14 April 2015 13:37:42 Ben Langfeld wrote:
Note that you could equally use add_path().
add_path(); msg_apply_changes();
Results in:
SIP/2.0 400 Bad Request. ... P-Registrar-Error: Path parse error. Server: kamailio (4.2.4 (x86_64/linux)).
Without msg_apply_changes it has no effect on the registered values in usrloc (path is null).
On 14/04/15 18:53, Daniel Tryba wrote:
On Tuesday 14 April 2015 13:37:42 Ben Langfeld wrote:
Note that you could equally use add_path().
add_path(); msg_apply_changes();
Results in:
SIP/2.0 400 Bad Request. ... P-Registrar-Error: Path parse error. Server: kamailio (4.2.4 (x86_64/linux)).
Without msg_apply_changes it has no effect on the registered values in usrloc (path is null).
Are you saying the result after msg_apply_changes() is a broken message? You can see what is there by printing $rb or $mb -- don't recall by heart which one is the entire buffer or the body.
Cheers, Daniel
On Wednesday 15 April 2015 14:03:16 Daniel-Constantin Mierla wrote:
add_path(); msg_apply_changes();
Are you saying the result after msg_apply_changes() is a broken message? You can see what is there by printing $rb or $mb -- don't recall by heart which one is the entire buffer or the body.
Apparent reason is add_path results in: Path: sip:;lr
The config is close to "standard", no listens, only add an alias="sip.pocos- voip.nl"
$mb: REGISTER sip:sip.pocos-voip.nl SIP/2.0#015#012Via: SIP/2.0/UDP 10.0.3.175:5555;branch=z9hG4bK-34fb1235#015#012From: "DT" sip:tst0@sip.pocos- voip.nl;tag=aff3ef534fac57f9o0#015#012To: "DT" sip:tst0@sip.pocos- voip.nl#015#012Call-ID: 3b3571bd-7d95a5ce@10.0.3.175#015#012CSeq: 10284 REGISTER#015#012Max-Forwards: 69#015#012Contact: "DT" sip:tst0@10.0.3.175:5555;expires=90#015#012User-Agent: Linksys/SPA962-6.1.3(a)#015#012Content-Length: 0#015#012Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER#015#012Supported: replaces#015#012Path: sip:;lr