Dear List.
I'm trying to issue an automatic unregister() (of a registration) when a websocket connection is closed. it is useful when the browser is closed without issuing REGISTER with expires=0.
i've tried implementing this using the event_route[websocket:closed] but i don't know how to find the registration uri from the $si:$sp. (that is needed for the unregister() function from the registrar module)
thanks for all replies in advance....
Hello,
When the register succeeds store the To-URI in a hash-table indexed on $si:$sp.
Make sure the entries in the hash-table do not automatically expire and use the sht_rm_name_re() function to remove the entry after you have called unregister.
Be careful using unregister() as unless you provide it the ruid for the exact location entry it will remove all contacts for that URI, not just the one relating to that connection. unregister() with ruid is only available in Git master. There is currently no way to find out what the ruid allocated after a save() is (but you could add this easily enough). Note: none of this is a problem if you are permitting only one contact binding per subscriber.
http://kamailio.org/docs/modules/devel/modules/registrar.html#idp126168 http://kamailio.org/docs/modules/devel/modules/registrar.html#idp1681984 http://kamailio.org/docs/modules/devel/modules/htable.html
Regards,
Peter
On 02/05/13 00:01, ???? ????? wrote:
Dear List.
I'm trying to issue an automatic unregister() (of a registration) when a websocket connection is closed. it is useful when the browser is closed without issuing REGISTER with expires=0.
i've tried implementing this using the event_route[websocket:closed] but i don't know how to find the registration uri from the $si:$sp. (that is needed for the unregister() function from the registrar module)
thanks for all replies in advance....
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
I should add... A better option is just to use an outbound edge proxy and remove the contact when you get a 430 response back from the edge proxy. This is the correct way to handle such things.
There are example configurations in the latest Git master (in the /examples directory).
On 02/05/13 14:02, Peter Dunkley wrote:
Hello,
When the register succeeds store the To-URI in a hash-table indexed on $si:$sp.
Make sure the entries in the hash-table do not automatically expire and use the sht_rm_name_re() function to remove the entry after you have called unregister.
Be careful using unregister() as unless you provide it the ruid for the exact location entry it will remove all contacts for that URI, not just the one relating to that connection. unregister() with ruid is only available in Git master. There is currently no way to find out what the ruid allocated after a save() is (but you could add this easily enough). Note: none of this is a problem if you are permitting only one contact binding per subscriber.
http://kamailio.org/docs/modules/devel/modules/registrar.html#idp126168 http://kamailio.org/docs/modules/devel/modules/registrar.html#idp1681984 http://kamailio.org/docs/modules/devel/modules/htable.html
Regards,
Peter
On 02/05/13 00:01, ???? ????? wrote:
Dear List.
I'm trying to issue an automatic unregister() (of a registration) when a websocket connection is closed. it is useful when the browser is closed without issuing REGISTER with expires=0.
i've tried implementing this using the event_route[websocket:closed] but i don't know how to find the registration uri from the $si:$sp. (that is needed for the unregister() function from the registrar module)
thanks for all replies in advance....
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
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
I've tried to implement the first method you've stated. it seems ok but i've found a more fundamental problem: The event_route[websocket:closed] is called only when i teminate the sip stack in my browser, but if i close the browser, without a "regular disconnect" then the w*ebsocket:closed event is not triggered*. (and this is my main target for the question) *how can i make it trigger ?*
p.s: about the outbound,path method, *is it a stable feature and bug-free ?*I see the default configuration is still using the nathelper hack instead of it.
regards.
2013/5/2 Peter Dunkley peter.dunkley@crocodile-rcs.com
I should add... A better option is just to use an outbound edge proxy and remove the contact when you get a 430 response back from the edge proxy. This is the correct way to handle such things.
There are example configurations in the latest Git master (in the /examples directory).
On 02/05/13 14:02, Peter Dunkley wrote:
Hello,
When the register succeeds store the To-URI in a hash-table indexed on $si:$sp.
Make sure the entries in the hash-table do not automatically expire and use the sht_rm_name_re() function to remove the entry after you have called unregister.
Be careful using unregister() as unless you provide it the ruid for the exact location entry it will remove all contacts for that URI, not just the one relating to that connection. unregister() with ruid is only available in Git master. There is currently no way to find out what the ruid allocated after a save() is (but you could add this easily enough). Note: none of this is a problem if you are permitting only one contact binding per subscriber.
http://kamailio.org/docs/modules/devel/modules/registrar.html#idp126168 http://kamailio.org/docs/modules/devel/modules/registrar.html#idp1681984 http://kamailio.org/docs/modules/devel/modules/htable.html
Regards,
Peter
On 02/05/13 00:01, אורן אברהם wrote:
Dear List.
I'm trying to issue an automatic unregister() (of a registration) when a websocket connection is closed. it is useful when the browser is closed without issuing REGISTER with expires=0.
i've tried implementing this using the event_route[websocket:closed] but i don't know how to find the registration uri from the $si:$sp. (that is needed for the unregister() function from the registrar module)
thanks for all replies in advance....
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing listsr-users@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing listsr-users@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
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 03/05/13 14:48, ???? ????? wrote:
I've tried to implement the first method you've stated. it seems ok but i've found a more fundamental problem: The event_route[websocket:closed] is called only when i teminate the sip stack in my browser, but if i close the browser, without a "regular disconnect" then the w_ebsocket:closed event is not triggered_. (and this is my main target for the question) *how can i make it trigger ?*
The websocket:closed event will be triggered when Kamailio next tries to send a WebSocket ping. Whether Kamailio does this at all (and how frequently it does it) depends entirely on how you've configured the WebSocket module.
p.s: about the outbound,path method, *is it a stable feature and bug-free ?* I see the default configuration is still using the nathelper hack instead of it.
I am using outbound in my deployments now. It is only available in Kamailio Git master. If stable and bug-free is an absolute requirement that you have then I strongly suggest you consider not using any SIP over WebSocket implementation that exists anywhere. This is brand-new technology and you are on the bleeding edge by using it. I would rate the stability of the Kamailio implementation against anything else you can find and I have no stability issues with it - but I strongly recommend you testing it thoroughly yourself and contributing bug-reports and fixes.
Regards,
Peter
When stating "stable" and "bug-free" - my intention was relativly to that feature in kamailio because it seems that it is still under development. Moreover - certainly if i will find any problem while testing i would submit a bug-report and bug-fixes if possible.
and by the way, I found another problem when implementing the first method: when calling unregister("location","websocket=>$si:$sp)" from the event_route[websocket:closed] i get the following error: *[parser/parse_to.c:879] : failed to parse To uri* why it happens and how can i fix it ? (i think it is related to the fact we call unregister from the event_route, but i'm not sure)
2013/5/3 Peter Dunkley peter.dunkley@crocodile-rcs.com
On 03/05/13 14:48, אורן אברהם wrote:
I've tried to implement the first method you've stated. it seems ok but i've found a more fundamental problem: The event_route[websocket:closed] is called only when i teminate the sip stack in my browser, but if i close the browser, without a "regular disconnect" then the w*ebsocket:closed event is not triggered*. (and this is my main target for the question) *how can i make it trigger ?*
The websocket:closed event will be triggered when Kamailio next tries to send a WebSocket ping. Whether Kamailio does this at all (and how frequently it does it) depends entirely on how you've configured the WebSocket module.
p.s: about the outbound,path method, *is it a stable feature and bug-free ?* I see the default configuration is still using the nathelper hack instead of it.
I am using outbound in my deployments now. It is only available in Kamailio Git master. If stable and bug-free is an absolute requirement that you have then I strongly suggest you consider not using any SIP over WebSocket implementation that exists anywhere. This is brand-new technology and you are on the bleeding edge by using it. I would rate the stability of the Kamailio implementation against anything else you can find and I have no stability issues with it - but I strongly recommend you testing it thoroughly yourself and contributing bug-reports and fixes.
Regards,
Peter
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
When stating "stable" and "bug-free" - my intention was relativly to that feature in kamailio because it seems that it is still under development. Moreover - certainly if i will find any problem while testing i would submit a bug-report and bug-fixes if possible.
and by the way, I found another problem when implementing the first method: when calling unregister("location","websocket=>$si:$sp)" from the event_route[websocket:closed] i get the following error: *[parser/parse_to.c:879] : failed to parse To uri* why it happens and how can i fix it ? (i think it is related to the fact we call unregister from the event_route, but i'm not sure)
You can't call unregister from that event_route.
2013/5/3 Peter Dunkley peter.dunkley@crocodile-rcs.com
On 03/05/13 14:48, אורן אברהם wrote:
I've tried to implement the first method you've stated. it seems ok but i've found a more fundamental problem: The event_route[websocket:closed] is called only when i teminate the sip stack in my browser, but if i close the browser, without a "regular disconnect" then the w*ebsocket:closed event is not triggered*. (and this is my main target for the question) *how can i make it trigger ?*
The websocket:closed event will be triggered when Kamailio next tries to send a WebSocket ping. Whether Kamailio does this at all (and how frequently it does it) depends entirely on how you've configured the WebSocket module.
p.s: about the outbound,path method, *is it a stable feature and bug-free ?* I see the default configuration is still using the nathelper hack instead of it.
I am using outbound in my deployments now. It is only available in Kamailio Git master. If stable and bug-free is an absolute requirement that you have then I strongly suggest you consider not using any SIP over WebSocket implementation that exists anywhere. This is brand-new technology and you are on the bleeding edge by using it. I would rate the stability of the Kamailio implementation against anything else you can find and I have no stability issues with it - but I strongly recommend you testing it thoroughly yourself and contributing bug-reports and fixes.
Regards,
Peter
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
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 Mon, May 6, 2013 at 4:19 PM, Peter Dunkley peter.dunkley@crocodile-rcs.com wrote:
and by the way, I found another problem when implementing the first method: when calling unregister("location","websocket=>$si:$sp)" from the event_route[websocket:closed] i get the following error: *[parser/parse_to.c:879] : failed to parse To uri* why it happens and how can i fix it ? (i think it is related to the fact we call unregister from the event_route, but i'm not sure)
You can't call unregister from that event_route.
Why we can't call unregister from event_route[websocket:closed]? Is it because it is just not implemented yet or we need big changes to implement it?
Thanks,
When you call unregister() without the new ruid parameter it parses the current SIP message to get information needed to do the unregister().
There is no real SIP message associated with an event_route[] so unregister() will not work.
The way to get this working is: 1) Use Git master so that unregister() with ruid is supported 2) Modify save() so that upon successful creation of new contact it copies the ruid created by usrloc into the sip_msg.ruid variable for the current SIP message. This means that on return from save() the $ruid PV will work. 3) Use a hash-table to store $ruid, $tU, and $td indexed on $si:$sp 4) Then when event_route[websocket:closed] is called you can retrieve the information from the hash table and call unregister(). Use the $tU and $td you have cached to construct the unregister() URI parameter.
Regards,
Peter
On Mon, May 6, 2013 at 4:19 PM, Peter Dunkley peter.dunkley@crocodile-rcs.com wrote:
and by the way, I found another problem when implementing the first method: when calling unregister("location","websocket=>$si:$sp)" from the event_route[websocket:closed] i get the following error: *[parser/parse_to.c:879] : failed to parse To uri* why it happens and how can i fix it ? (i think it is related to the fact we call unregister from the event_route, but i'm not sure)
You can't call unregister from that event_route.
Why we can't call unregister from event_route[websocket:closed]? Is it because it is just not implemented yet or we need big changes to implement it?
Thanks,
-- Iwan Budi Kusnanto
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
Hello,
On 5/11/13 11:28 AM, Peter Dunkley wrote:
When you call unregister() without the new ruid parameter it parses the current SIP message to get information needed to do the unregister().
There is no real SIP message associated with an event_route[] so unregister() will not work.
The way to get this working is:
- Use Git master so that unregister() with ruid is supported
- Modify save() so that upon successful creation of new contact it copies
the ruid created by usrloc into the sip_msg.ruid variable for the current SIP message. This means that on return from save() the $ruid PV will work.
this topic was questioned in at least another email and I forgot to answer. Actually save() can store the ruid in an xavp, one has to set the module parameter:
http://kamailio.org/docs/modules/stable/modules/registrar.html#idp1752184
But now that ruid is part of sip message structure, might be good to store it there, could be faster accessed.
Cheers, Daniel
- Use a hash-table to store $ruid, $tU, and $td indexed on $si:$sp
- Then when event_route[websocket:closed] is called you can retrieve the
information from the hash table and call unregister(). Use the $tU and $td you have cached to construct the unregister() URI parameter.
Regards,
Peter
On Mon, May 6, 2013 at 4:19 PM, Peter Dunkley peter.dunkley@crocodile-rcs.com wrote:
and by the way, I found another problem when implementing the first method: when calling unregister("location","websocket=>$si:$sp)" from the event_route[websocket:closed] i get the following error: *[parser/parse_to.c:879] : failed to parse To uri* why it happens and how can i fix it ? (i think it is related to the fact we call unregister from the event_route, but i'm not sure)
You can't call unregister from that event_route.
Why we can't call unregister from event_route[websocket:closed]? Is it because it is just not implemented yet or we need big changes to implement it?
Thanks,
-- Iwan Budi Kusnanto
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
Hi. Just for the record, I found another way to acheve the "unregister" in my case (but maybe someone else still needs to above method...) : I've saved some info from the REGISTER message in an HTABLE and used the UAC module to send an unregister message (same as the original, just changed the 'expires' contact parameter to 0)
(and i think there is a bug in the UAC module - it creates messages with a null body that dosen't pass the sanity module check, so i've disabled the failing test for all REGISTER messages.)
2013/5/11 Daniel-Constantin Mierla miconda@gmail.com
Hello,
On 5/11/13 11:28 AM, Peter Dunkley wrote:
When you call unregister() without the new ruid parameter it parses the current SIP message to get information needed to do the unregister().
There is no real SIP message associated with an event_route[] so unregister() will not work.
The way to get this working is:
- Use Git master so that unregister() with ruid is supported
- Modify save() so that upon successful creation of new contact it copies
the ruid created by usrloc into the sip_msg.ruid variable for the current SIP message. This means that on return from save() the $ruid PV will work.
this topic was questioned in at least another email and I forgot to answer. Actually save() can store the ruid in an xavp, one has to set the module parameter:
http://kamailio.org/docs/**modules/stable/modules/** registrar.html#idp1752184http://kamailio.org/docs/modules/stable/modules/registrar.html#idp1752184
But now that ruid is part of sip message structure, might be good to store it there, could be faster accessed.
Cheers, Daniel
- Use a hash-table to store $ruid, $tU, and $td indexed on $si:$sp
- Then when event_route[websocket:closed] is called you can retrieve the
information from the hash table and call unregister(). Use the $tU and $td you have cached to construct the unregister() URI parameter.
Regards,
Peter
On Mon, May 6, 2013 at 4:19 PM, Peter Dunkley
<peter.dunkley@crocodile-rcs.**com peter.dunkley@crocodile-rcs.com> wrote:
and by the way, I found another problem when implementing the first
method: when calling unregister("location","**websocket=>$si:$sp)" from the event_route[websocket:closed] i get the following error: *[parser/parse_to.c:879] : failed to parse To uri* why it happens and how can i fix it ? (i think it is related to the fact we call unregister from the event_route, but i'm not sure)
You can't call unregister from that event_route.
Why we can't call unregister from event_route[websocket:closed]? Is it because it is just not implemented yet or we need big changes to implement it?
Thanks,
-- Iwan Budi Kusnanto
______________________________**_________________ 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-**usershttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierla - http://www.asipto.com http://twitter.com/#!/miconda - http://www.linkedin.com/in/**micondahttp://www.linkedin.com/in/miconda Kamailio Advanced Training, San Francisco, USA - June 24-27, 2013
______________________________**_________________ 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-**usershttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Peter Dunkley writes:
- Use a hash-table to store $ruid, $tU, and $td indexed on $si:$sp
- Then when event_route[websocket:closed] is called you can retrieve the
information from the hash table and call unregister(). Use the $tU and $td you have cached to construct the unregister() URI parameter.
why does unregister need $tU and $td params, because $ruid alone uniquely identifies the contact to be unregistered?
-- juha
The usrloc function that locates a record by ruid takes in an aorhash value as an argument (and to get the aorhash value you need the AoR).
I suppose an alternative function that just needs ruid could be written - but it would be much less efficient as it would have to linearly search all records (unless an additional hash on ruid is added - and a DB index on it too).
Regards,
Peter
I suppose you could write a new function that just
Peter Dunkley writes:
- Use a hash-table to store $ruid, $tU, and $td indexed on $si:$sp
- Then when event_route[websocket:closed] is called you can retrieve
the information from the hash table and call unregister(). Use the $tU and $td you have cached to construct the unregister() URI parameter.
why does unregister need $tU and $td params, because $ruid alone uniquely identifies the contact to be unregistered?
-- juha
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
Peter Dunkley writes:
I suppose an alternative function that just needs ruid could be written - but it would be much less efficient as it would have to linearly search all records (unless an additional hash on ruid is added - and a DB index on it too).
thanks for the explanation. now that we have ruid, the rest of usrloc has not clearly kept up with it. a new hash on ruid should be added. usrloc table already has unique index on ruid, which means that in db only mode, it should be quite easy to make the query only based on ruid.
-- juha
On 5/13/13 6:44 AM, Juha Heinanen wrote:
Peter Dunkley writes:
I suppose an alternative function that just needs ruid could be written - but it would be much less efficient as it would have to linearly search all records (unless an additional hash on ruid is added - and a DB index on it too).
thanks for the explanation. now that we have ruid, the rest of usrloc has not clearly kept up with it. a new hash on ruid should be added. usrloc table already has unique index on ruid, which means that in db only mode, it should be quite easy to make the query only based on ruid.
For db only the sql query can be done only on ruid (for update and delete), there is a parameter for that now.
The aor is needed for memory, because the records are indexed in order to be able to find on save() and lookup() where the aor is in the sip message. Adding a second hash table just to index on ruid will make things more complex from point of view of memory use and synchronization between the two hashes.
I said in another email that actually the aorhash is needed, but if aor is known, computing aorhash is trivial.
Cheers, Daniel
Daniel-Constantin Mierla writes:
For db only the sql query can be done only on ruid (for update and delete), there is a parameter for that now.
yes, but at least in case of unregister, the implementation is inefficient, because before calling delete, it needs to call get:
if (ul.get_urecord_by_ruid_d, ul.get_aorhash(&aor), _ruid, &r, &c) != 0) { LM_WARN("AOR/Contact not found\n"); return -1; } if (ul.delete_ucontact(r, c) != 0) { LM_WARN("could not delete contact\n"); return -1; }
that results in two db queries instead of one. another disadvantage is that aor needs to be available when unregister is called.
i'm currently testing new version of unregister that (if uri param is empty string), calls new ul api function delete_urecord_by_ruid.
once i get it tested, i would like to commit the code, because then unregister can be done more efficiently and without knowing what the aor is.
-- juha