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?
On Sun, May 3, 2015 at 7:21 PM, mayamatakeshi mayamatakeshi@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; }
Regards, Takeshi
On Mon, May 4, 2015 at 5:05 PM, mayamatakeshi mayamatakeshi@gmail.com wrote:
On Sun, May 3, 2015 at 7:21 PM, mayamatakeshi mayamatakeshi@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?
Regards, Takeshi
On Mon, May 4, 2015 at 5:22 PM, mayamatakeshi mayamatakeshi@gmail.com wrote:
On Mon, May 4, 2015 at 5:05 PM, mayamatakeshi mayamatakeshi@gmail.com wrote:
On Sun, May 3, 2015 at 7:21 PM, mayamatakeshi mayamatakeshi@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?
Regards, Takeshi
On Mon, May 4, 2015 at 5:36 PM, mayamatakeshi mayamatakeshi@gmail.com wrote:
On Mon, May 4, 2015 at 5:22 PM, mayamatakeshi mayamatakeshi@gmail.com wrote:
On Mon, May 4, 2015 at 5:05 PM, mayamatakeshi mayamatakeshi@gmail.com wrote:
On Sun, May 3, 2015 at 7:21 PM, mayamatakeshi mayamatakeshi@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