<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 4, 2015 at 5:22 PM, mayamatakeshi <span dir="ltr"><<a href="mailto:mayamatakeshi@gmail.com" target="_blank">mayamatakeshi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Mon, May 4, 2015 at 5:05 PM, mayamatakeshi <span dir="ltr"><<a href="mailto:mayamatakeshi@gmail.com" target="_blank">mayamatakeshi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Sun, May 3, 2015 at 7:21 PM, mayamatakeshi <span dir="ltr"><<a href="mailto:mayamatakeshi@gmail.com" target="_blank">mayamatakeshi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Hello,</div><div><br></div><div>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?</div></div></blockquote><div><br></div></span><div>Hello, I have found a way to do it using htable.</div><div>Here is the gist of it in case someone else needs this:</div><div><br></div><div><br></div><div>loadmodule "xhttp.so"</div><div>loadmodule "websocket.so"</div><div><br></div><div>modparam("htable", "htable", "websocket=>size=10")  <br></div><div><br></div><div>route {</div><div>    if(proto == WS) {</div><div>        xlog("L_DEBUG", "WebSocket check: conid=$conid val=$sht(websocket=>$conid)\n");</div><div>    }</div><div>}</div><div><br></div><div>event_route[xhttp:request] {</div><div>    if (ws_handle_handshake()) {</div><div>        # successful connection</div><div><span style="white-space:pre-wrap">   </span>#adding $conid to hash table</div><div>        $sht(websocket=>$conid) = $hu; </div><div>        exit;</div><div>     }</div><div>}</div><div><br></div><div>event_route[websocket:closed] {</div><div>    xlog("L_DEBUG", "WebSocket connection from $si:$sp has closed\n");</div><div>    # deleting $conid from hash table</div><div>    $sht(websocket=>$conid) = $null;</div><div>}</div><div></div></div></div></div></blockquote><div><br></div></div></div><div>Checking again, deletion of the entry in the hash table is failing.</div><div><br></div><div>In older versions of kamailio, if I am not mistaken, i used:</div><div>  $sht(websocket=>$conid) = null;<br></div><div>but it seems in recent version null was replaced with $null (as if i use null, kamailio will not start)</div><div>so I am using</div><div>    $sht(websocket=>$conid) = $null;<br></div><div>but it seems this doesn't work.</div><div>So, how do we currently delete an htable entry at config file?</div></div></div></div></blockquote><div><br></div><div>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.</div><div>I confirmed this by using this:</div><div><div>    xlog("L_ERR", "WebSocket connection from $si:$sp has closed. conid=$conid\n");</div></div><div><br></div><div>/usr/local/src/git/sip-router-4.2/kamailio[6443]: ERROR: WebSocket connection from <a href="http://192.168.2.33:63179">192.168.2.33:63179</a> has closed. conid=<null><br></div><div><br></div><div>Wouldn't this be a bug? Shouldn't the $conid be available when that event happens?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><pre style="font-family:courier,'courier new',monospace;font-size:14px;white-space:pre-wrap;word-wrap:break-word;margin:0em;color:rgb(160,30,30);line-height:19.6000003814697px"><span style="font-family:arial,sans-serif;font-size:small;line-height:normal;color:rgb(34,34,34)"> </span><br></pre></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> <br><br></div><div>Regards,</div><div>Takeshi</div></div></div></div>
</blockquote></div><br></div></div>
</blockquote></div><br></div></div>