In case both your kamailio installation and your apache webserver are in the same machine, it is not going to work with the kamailio config example as is.<div><br></div><div>There's probably an error reported in kamaiio's log file so you should check it out. In my case, I had to comment out parts of the script that were in charge of doing some validation, particularly, in event_route[xhttp:request].</div>
<div><br></div><div>Also, the port I used for signaling in the call.htm (sipml5) is 5060, not 80. This is because xhttp listens for TCP connections on that port.</div><div><br></div><div>Regards.</div><div><br></div><div>
Carlos.</div><div><br></div><div><div>event_route[xhttp:request] {</div><div> set_reply_close();</div><div> set_reply_no_connect();</div><div><br></div><div># if ($Rp != MY_WS_PORT && $Rp != MY_WSS_PORT) {</div>
<div># xlog("L_WARN", "HTTP request received on $Rp\n");</div><div># xhttp_reply("403", "Forbidden", "", "");</div><div># exit;</div>
<div># }</div><div><br></div><div> xlog("L_ALERT", "HTTP Request Received\n");</div><div><br></div><div> if ($hdr(Upgrade)=~"websocket"</div><div> && $hdr(Connection)=~"Upgrade"</div>
<div> && $rm=~"GET") {</div><div> xlog("L_DBG", "WebSocket\n");</div><div> xlog("L_DBG", " Host: $hdr(Host)\n");</div>
<div> xlog("L_DBG", " Origin: $hdr(Origin)\n");</div><div><br></div><div><br></div><div># if ($hdr(Host) == $null || !is_myself($hdr(Host))) {</div><div># xlog("L_WARN", "Bad host $hdr(Host)\n");</div>
<div># xhttp_reply("403", "Forbidden", "", "");</div><div># exit;</div><div># }</div><div><br></div><div> # Optional... validate Origin</div>
<div> # Optional... perform HTTP authentication</div><div><br></div><div> # ws_handle_handshake() exits (no further configuration file</div><div> # processing of the request) when complete.</div>
<div> if (ws_handle_handshake())</div><div> return;</div><div> }</div><div><br></div><div> xhttp_reply("404", "Not found", "", "");</div>
<div>}</div><br><div class="gmail_quote">On Tue, Aug 14, 2012 at 6:13 PM, Juan Castro <span dir="ltr"><<a href="mailto:jcastro@instant.com.br" target="_blank">jcastro@instant.com.br</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Well, not the <a href="http://simpl5.org" target="_blank">simpl5.org</a> site itself, since it uses its own<br>
Websocket-SIP gateway to make calls. I downloaded their code and<br>
changed the gateway address from "<a href="http://sipml5.org" target="_blank">sipml5.org</a>" to "192.168.0.148" which<br>
is the VM where I'm testing. Also, Apache is using ports 8000 and 4443<br>
since Kamailio uses 80 and 443.<br>
<br>
But when I try to make a call, filling 192.168.0.48 as the realm, I<br>
get "Disconnected: Failed to connet to the server" from the call.htm<br>
page. I monitored packets with Wireshark and I see no traffic that<br>
would make sense between the machine with the browser and the one with<br>
Kamailio. I suspect I have to make more changes in the <a href="http://sipml5.org" target="_blank">sipml5.org</a><br>
Javascript, am I correct?<br>
<br>
Kamailio itself (Dev version) is up and running and normal SIP from<br>
normal UAs works. Here's the config I'm using. It's the example in the<br>
websocket module directory, just changed to use my db and the default<br>
TLS cert that was installed:<br>
<br>
----------------------------------------------------------------------<br>
#!KAMAILIO<br>
#<br>
# Simple/sample kamailio.cfg for running a proxy/registrar with TLS and<br>
# WebSockets support.<br>
<br>
#!substdef "!DBURL!mysql://ser:heslo@localhost/ser!g"<br>
#!substdef "!MY_IP_ADDR!192.168.0.148!g"<br>
#!substdef "!MY_WS_PORT!80!g"<br>
#!substdef "!MY_WSS_PORT!443!g"<br>
#!substdef "!MY_WS_ADDR!tcp:MY_IP_ADDR:MY_WS_PORT!g"<br>
#!substdef "!MY_WSS_ADDR!tls:MY_IP_ADDR:MY_WSS_PORT!g"<br>
<br>
##!define LOCAL_TEST_RUN<br>
#!define WITH_TLS<br>
#!define WITH_WEBSOCKETS<br>
<br>
<br>
####### Global Parameters #########<br>
<br>
fork=yes<br>
children=4<br>
<br>
#alias="<a href="http://example.com" target="_blank">example.com</a>"<br>
<br>
#!ifdef WITH_TLS<br>
enable_tls=1<br>
#!endif<br>
<br>
listen=MY_IP_ADDR<br>
#!ifdef WITH_WEBSOCKETS<br>
listen=MY_WS_ADDR<br>
#!ifdef WITH_TLS<br>
listen=MY_WSS_ADDR<br>
#!endif<br>
#!endif<br>
<br>
tcp_connection_lifetime=3604<br>
tcp_accept_no_cl=yes<br>
tcp_rd_buf_size=16384<br>
<br>
syn_branch=0<br>
debug=2<br>
<br>
# set paths to location of modules (to sources or installation folders)<br>
#!ifdef WITH_SRCPATH<br>
mpath="modules_k:modules"<br>
#!else<br>
mpath="/usr/local/kamailio/lib/kamailio/modules_k/:/usr/local/kamailio/lib/kamailio/modules/"<br>
#!endif<br>
<br>
loadmodule "db_mysql.so"<br>
loadmodule "tm.so"<br>
loadmodule "sl.so"<br>
loadmodule "rr.so"<br>
loadmodule "pv.so"<br>
loadmodule "maxfwd.so"<br>
loadmodule "usrloc.so"<br>
loadmodule "registrar.so"<br>
loadmodule "textops.so"<br>
loadmodule "siputils.so"<br>
loadmodule "xlog.so"<br>
loadmodule "sanity.so"<br>
loadmodule "ctl.so"<br>
loadmodule "auth.so"<br>
loadmodule "auth_db.so"<br>
loadmodule "kex.so"<br>
loadmodule "mi_rpc.so"<br>
#!ifdef WITH_TLS<br>
loadmodule "tls.so"<br>
#!endif<br>
#!ifdef WITH_WEBSOCKETS<br>
loadmodule "xhttp.so"<br>
loadmodule "websocket.so"<br>
loadmodule "nathelper.so"<br>
#!endif<br>
<br>
# ----------------- setting module-specific parameters ---------------<br>
<br>
# ----- tm params -----<br>
# auto-discard branches from previous serial forking leg<br>
modparam("tm", "failure_reply_mode", 3)<br>
# default retransmission timeout: 30sec<br>
modparam("tm", "fr_timer", 30000)<br>
# default invite retransmission timeout after 1xx: 120sec<br>
modparam("tm", "fr_inv_timer", 120000)<br>
<br>
# ----- rr params -----<br>
# add value to ;lr param to cope with most of the UAs<br>
modparam("rr", "enable_full_lr", 1)<br>
# do not append from tag to the RR (no need for this script)<br>
modparam("rr", "append_fromtag", 0)<br>
<br>
# ----- registrar params -----<br>
modparam("registrar", "method_filtering", 1)<br>
modparam("registrar", "max_expires", 3600)<br>
modparam("registrar", "gruu_enabled", 0)<br>
<br>
# ----- usrloc params -----<br>
modparam("usrloc", "db_url", "DBURL")<br>
modparam("usrloc", "db_mode", 0)<br>
<br>
# ----- auth_db params -----<br>
modparam("auth_db", "db_url", "DBURL")<br>
modparam("auth_db", "calculate_ha1", yes)<br>
modparam("auth_db", "password_column", "password")<br>
modparam("auth_db", "load_credentials", "")<br>
<br>
#!ifdef WITH_TLS<br>
# ----- tls params -----<br>
modparam("tls", "config", "/usr/local/kamailio/etc/kamailio/tls.cfg")<br>
#!endif<br>
<br>
#!ifdef WITH_WEBSOCKETS<br>
# ----- nathelper params -----<br>
modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")<br>
# Note: leaving NAT pings turned off here as nathelper is _only_ being used for<br>
# WebSocket connections. NAT pings are not needed as WebSockets have<br>
# their own keep-alives.<br>
#!endif<br>
<br>
<br>
####### Routing Logic ########<br>
<br>
# Main SIP request routing logic<br>
# - processing of any incoming SIP request starts with this route<br>
# - note: this is the same as route { ... }<br>
request_route {<br>
<br>
# per request initial checks<br>
route(REQINIT);<br>
<br>
#!ifdef WITH_WEBSOCKETS<br>
if (nat_uac_test(64)) {<br>
# Do NAT traversal stuff for requests from a WebSocket<br>
# connection - even if it is not behind a NAT!<br>
# This won't be needed in the future if Kamailio and the<br>
# WebSocket client support Outbound and Path.<br>
force_rport();<br>
if (is_method("REGISTER"))<br>
fix_nated_register();<br>
else {<br>
if (!add_contact_alias()) {<br>
xlog("L_ERR", "Error aliasing contact <$ct>\n");<br>
sl_send_reply("400", "Bad Request");<br>
exit;<br>
}<br>
}<br>
}<br>
#!endif<br>
<br>
# handle requests within SIP dialogs<br>
route(WITHINDLG);<br>
<br>
### only initial requests (no To tag)<br>
<br>
# CANCEL processing<br>
if (is_method("CANCEL")) {<br>
if (t_check_trans())<br>
t_relay();<br>
exit;<br>
}<br>
<br>
t_check_trans();<br>
<br>
# authentication<br>
route(AUTH);<br>
<br>
# record routing for dialog forming requests (in case they are routed)<br>
# - remove preloaded route headers<br>
remove_hf("Route");<br>
if (is_method("INVITE"))<br>
record_route();<br>
<br>
# handle registrations<br>
route(REGISTRAR);<br>
<br>
if ($rU==$null) {<br>
# request with no Username in RURI<br>
sl_send_reply("484","Address Incomplete");<br>
exit;<br>
}<br>
<br>
# user location service<br>
route(LOCATION);<br>
<br>
route(RELAY);<br>
}<br>
<br>
route[RELAY] {<br>
if (!t_relay()) {<br>
sl_reply_error();<br>
}<br>
exit;<br>
}<br>
<br>
# Per SIP request initial checks<br>
route[REQINIT] {<br>
if (!mf_process_maxfwd_header("10")) {<br>
sl_send_reply("483","Too Many Hops");<br>
exit;<br>
}<br>
<br>
if(!sanity_check("1511", "7")) {<br>
xlog("Malformed SIP message from $si:$sp\n");<br>
exit;<br>
}<br>
}<br>
<br>
# Handle requests within SIP dialogs<br>
route[WITHINDLG] {<br>
if (has_totag()) {<br>
# sequential request withing a dialog should<br>
# take the path determined by record-routing<br>
if (loose_route()) {<br>
#!ifdef WITH_WEBSOCKETS<br>
if ($du == "") {<br>
if (!handle_ruri_alias()) {<br>
xlog("L_ERR", "Bad alias <$ru>\n");<br>
sl_send_reply("400", "Bad Request");<br>
exit;<br>
}<br>
}<br>
#!endif<br>
route(RELAY);<br>
} else {<br>
if ( is_method("ACK") ) {<br>
if ( t_check_trans() ) {<br>
# no loose-route, but stateful ACK;<br>
# must be an ACK after a 487<br>
# or e.g. 404 from upstream server<br>
t_relay();<br>
exit;<br>
} else {<br>
# ACK without matching transaction...<br>
# ignore and discard<br>
exit;<br>
}<br>
}<br>
sl_send_reply("404","Not here");<br>
}<br>
exit;<br>
}<br>
}<br>
<br>
# Handle SIP registrations<br>
route[REGISTRAR] {<br>
if (is_method("REGISTER")) {<br>
if (!save("location"))<br>
sl_reply_error();<br>
<br>
exit;<br>
}<br>
}<br>
<br>
# USER location service<br>
route[LOCATION] {<br>
if (!lookup("location")) {<br>
$var(rc) = $rc;<br>
t_newtran();<br>
switch ($var(rc)) {<br>
case -1:<br>
case -3:<br>
send_reply("404", "Not Found");<br>
exit;<br>
case -2:<br>
send_reply("405", "Method Not Allowed");<br>
exit;<br>
}<br>
}<br>
}<br>
<br>
# Authentication route<br>
route[AUTH] {<br>
if (is_method("REGISTER") || from_uri==myself) {<br>
# authenticate requests<br>
if (!auth_check("$fd", "subscriber", "1")) {<br>
auth_challenge("$fd", "0");<br>
exit;<br>
}<br>
# user authenticated - remove auth header<br>
if(!is_method("REGISTER"))<br>
consume_credentials();<br>
}<br>
# if caller is not local subscriber, then check if it calls<br>
# a local destination, otherwise deny, not an open relay here<br>
if (from_uri!=myself && uri!=myself) {<br>
sl_send_reply("403","Not relaying");<br>
exit;<br>
}<br>
}<br>
<br>
#!ifdef WITH_WEBSOCKETS<br>
onreply_route {<br>
if (nat_uac_test(64)) {<br>
# Do NAT traversal stuff for replies to a WebSocket connection<br>
# - even if it is not behind a NAT!<br>
# This won't be needed in the future if Kamailio and the<br>
# WebSocket client support Outbound and Path.<br>
add_contact_alias();<br>
}<br>
}<br>
<br>
event_route[xhttp:request] {<br>
set_reply_close();<br>
set_reply_no_connect();<br>
<br>
if ($Rp != MY_WS_PORT && $Rp != MY_WSS_PORT) {<br>
xlog("L_WARN", "HTTP request received on $Rp\n");<br>
xhttp_reply("403", "Forbidden", "", "");<br>
exit;<br>
}<br>
<br>
xlog("L_DBG", "HTTP Request Received\n");<br>
<br>
if ($hdr(Upgrade)=~"websocket"<br>
&& $hdr(Connection)=~"Upgrade"<br>
&& $rm=~"GET") {<br>
xlog("L_DBG", "WebSocket\n");<br>
xlog("L_DBG", " Host: $hdr(Host)\n");<br>
xlog("L_DBG", " Origin: $hdr(Origin)\n");<br>
<br>
if ($hdr(Host) == $null || !is_myself($hdr(Host))) {<br>
xlog("L_WARN", "Bad host $hdr(Host)\n");<br>
xhttp_reply("403", "Forbidden", "", "");<br>
exit;<br>
}<br>
<br>
# Optional... validate Origin<br>
# Optional... perform HTTP authentication<br>
<br>
# ws_handle_handshake() exits (no further configuration file<br>
# processing of the request) when complete.<br>
if (ws_handle_handshake())<br>
{<br>
# Optional... cache some information abou the<br>
# successful connection<br>
exit;<br>
}<br>
}<br>
<br>
xhttp_reply("404", "Not found", "", "");<br>
}<br>
<br>
event_route[websocket:closed] {<br>
xlog("L_INFO", "WebSocket connection from $si:$sp has closed\n");<br>
}<br>
#!endif<br>
----------------------------------------------------------------------<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Juan Carlos Castro y Castro<br>
Instant Solutions - Telefonia Gerando Resultado<br>
<a href="http://www.instant.com.br" target="_blank">http://www.instant.com.br</a><br>
Principais capitais: 4063-6100<br>
Demais regiões: (11)4063-6100<br>
<br>
_______________________________________________<br>
sr-dev mailing list<br>
<a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
</font></span></blockquote></div><br></div>