[SR-Users] SIP 500 on WSS connection lookup failure

Daniel-Constantin Mierla miconda at gmail.com
Fri Mar 6 21:32:49 CET 2015


Hello,

On 06/03/15 03:38, Armen Babikyan wrote:
> Hello,
>
> I am setting up this scenario using Kamailio 4.2.2:
>
> [UA] <-> [kamailio1] <-> [kamailio2] <-> [other stuff]
>
> UA connects to kamailio1 using SIP/WSS, kamailio1 proxies request
> along to kamailio2.  Note that my intent here is to have kamailio2
> provide the registrar functionality.  The kamailio2 (or something
> behind it) can also initiate transactions to UA, like OPTIONS, for
> example.
>
> I'm having an issue though: when the websocket connection between
> kamailio1 and UA dies, transaction requests from kamailio2 show up to
> kamailio1, and I get errors in kamailio1's logs because the WSS
> connection is gone.  I get messages as follows (debug=2):
>
> Mar  6 00:17:33 kamailio1 /usr/local/sbin/kamailio[5653]: WARNING:
> <core> [msg_translator.c:2778]: via_builder(): TCP/TLS connection (id:
> 0) for WebSocket could not be found
> Mar  6 00:17:33 kamailio1 /usr/local/sbin/kamailio[5653]: ERROR:
> <core> [msg_translator.c:1996]: build_req_buf_from_sip_req(): could
> not create Via header
> Mar  6 00:17:33 kamailio1 /usr/local/sbin/kamailio[5653]: ERROR: tm
> [t_fwd.c:527]: prepare_new_uac(): could not build request
> Mar  6 00:17:33 kamailio1 /usr/local/sbin/kamailio[5653]: ERROR: tm
> [t_fwd.c:1777]: t_forward_nonack(): ERROR: t_forward_nonack: failure
> to add branches
>
> At debug=4, I get the output here: http://pastebin.com/d3RumekG
>
> In a running tshark, I see kamailio1 responding to kamailio2 with a
> "SIP/2.0 500 No error (2/TM)".  It appears to me that this is
> happening before t_relay() even returns.
>
> Is there a way to prevent the SIP 500 from being sent back to the
> client?  I am calling t_on_branch_failure("kam2bf") and
> t_on_failure("kam2f"), with each of those handlers
> (event_route[tm:branch-failure:kam2bf] and failure_route[kam2f])
> written to print a log message, but it appears that neither of those
> handlers are being called.  I tried installing these handlers
> independently to no avail.
>
> I also tried registering a t_on_reply() handler, thinking it was an
> internally-generated SIP response that might make it through my
> handler on its way out to kam2, but that is also not getting invoked.
>
> I want to return a 404 or something similar instead of having a 500
> auto-returned for me.
>
> Related to this, is there a way to query kamailio's in-memory client
> connectivity data structure for the connectivity status of a client?
> Or is this something best done by keeping track of every client myself
> using (e.g.) localcache?
>
> Any pointers are appreciated.  Thanks!

If you want tm not to send an reply internally, see:

-
http://kamailio.org/docs/modules/4.2.x/modules/tm.html#tm.f.t_set_disable_internal_reply

Also, you can list the details of tcp connections via tcp -- see 'kamcmd
help' for the tcp related commands. Iirc, something similar should be
for websocket connections.

The usrloc module keeps the id of the tcp connection for the client, the
development version (master branch) has the option to delete the record
if the connection is gone. For older versions there is also an option to
remove those records with some delay
(http://kamailio.org/docs/modules/4.2.x/modules/usrloc.html#usrloc.p.handle_lost_tcp),
being a timer based cleanup.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, May 27-29, 2015
Berlin, Germany - http://www.kamailioworld.com




More information about the sr-users mailing list