[SR-Users] WebSocket data in TCP connection

mayamatakeshi mayamatakeshi at gmail.com
Mon May 4 10:39:37 CEST 2015


On Mon, May 4, 2015 at 5:36 PM, mayamatakeshi <mayamatakeshi at gmail.com>
wrote:

>
>
> On Mon, May 4, 2015 at 5:22 PM, mayamatakeshi <mayamatakeshi at gmail.com>
> wrote:
>
>>
>>
>> On Mon, May 4, 2015 at 5:05 PM, mayamatakeshi <mayamatakeshi at gmail.com>
>> wrote:
>>
>>>
>>>
>>> On Sun, May 3, 2015 at 7:21 PM, mayamatakeshi <mayamatakeshi at gmail.com>
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> about module websocket, is it possible to associate a value with the
>>>> TCP connection and have this value readable when handling SIP requests on
>>>> that connection?
>>>>
>>>
>>> Hello, I have found a way to do it using htable.
>>> Here is the gist of it in case someone else needs this:
>>>
>>>
>>> loadmodule "xhttp.so"
>>> loadmodule "websocket.so"
>>>
>>> modparam("htable", "htable", "websocket=>size=10")
>>>
>>> route {
>>>     if(proto == WS) {
>>>         xlog("L_DEBUG", "WebSocket check: conid=$conid
>>> val=$sht(websocket=>$conid)\n");
>>>     }
>>> }
>>>
>>> event_route[xhttp:request] {
>>>     if (ws_handle_handshake()) {
>>>         # successful connection
>>> #adding $conid to hash table
>>>         $sht(websocket=>$conid) = $hu;
>>>         exit;
>>>      }
>>> }
>>>
>>> event_route[websocket:closed] {
>>>     xlog("L_DEBUG", "WebSocket connection from $si:$sp has closed\n");
>>>     # deleting $conid from hash table
>>>     $sht(websocket=>$conid) = $null;
>>> }
>>>
>>
>> Checking again, deletion of the entry in the hash table is failing.
>>
>> In older versions of kamailio, if I am not mistaken, i used:
>>   $sht(websocket=>$conid) = null;
>> but it seems in recent version null was replaced with $null (as if i use
>> null, kamailio will not start)
>> so I am using
>>     $sht(websocket=>$conid) = $null;
>> but it seems this doesn't work.
>> So, how do we currently delete an htable entry at config file?
>>
>
> My mistake. htable entry deletion by assignment to $null does work, the
> problem is that when we get websocked:closed, $conid is not valid anymore.
> I confirmed this by using this:
>     xlog("L_ERR", "WebSocket connection from $si:$sp has closed.
> conid=$conid\n");
>
> /usr/local/src/git/sip-router-4.2/kamailio[6443]: ERROR: WebSocket
> connection from 192.168.2.33:63179 has closed. conid=<null>
>
> Wouldn't this be a bug? Shouldn't the $conid be available when that event
> happens?
>

Ah, nevermind,
I just need to use $si:$sp as htable key instead of $conid.


>
>
>>
>>
>>
>>>
>>> Regards,
>>> Takeshi
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20150504/7547abc7/attachment.html>


More information about the sr-users mailing list