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&#39;s probably an error reported in kamaiio&#39;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 &amp;&amp; $Rp != MY_WSS_PORT) {</div>
<div>#               xlog(&quot;L_WARN&quot;, &quot;HTTP request received on $Rp\n&quot;);</div><div>#               xhttp_reply(&quot;403&quot;, &quot;Forbidden&quot;, &quot;&quot;, &quot;&quot;);</div><div>#               exit;</div>
<div>#       }</div><div><br></div><div>        xlog(&quot;L_ALERT&quot;, &quot;HTTP Request Received\n&quot;);</div><div><br></div><div>        if ($hdr(Upgrade)=~&quot;websocket&quot;</div><div>                        &amp;&amp; $hdr(Connection)=~&quot;Upgrade&quot;</div>
<div>                        &amp;&amp; $rm=~&quot;GET&quot;) {</div><div>                xlog(&quot;L_DBG&quot;, &quot;WebSocket\n&quot;);</div><div>                xlog(&quot;L_DBG&quot;, &quot; Host: $hdr(Host)\n&quot;);</div>
<div>                xlog(&quot;L_DBG&quot;, &quot; Origin: $hdr(Origin)\n&quot;);</div><div><br></div><div><br></div><div>#               if ($hdr(Host) == $null || !is_myself($hdr(Host))) {</div><div>#                       xlog(&quot;L_WARN&quot;, &quot;Bad host $hdr(Host)\n&quot;);</div>
<div>#                       xhttp_reply(&quot;403&quot;, &quot;Forbidden&quot;, &quot;&quot;, &quot;&quot;);</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(&quot;404&quot;, &quot;Not found&quot;, &quot;&quot;, &quot;&quot;);</div>
<div>}</div><br><div class="gmail_quote">On Tue, Aug 14, 2012 at 6:13 PM, Juan Castro <span dir="ltr">&lt;<a href="mailto:jcastro@instant.com.br" target="_blank">jcastro@instant.com.br</a>&gt;</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 &quot;<a href="http://sipml5.org" target="_blank">sipml5.org</a>&quot; to &quot;192.168.0.148&quot; which<br>
is the VM where I&#39;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 &quot;Disconnected: Failed to connet to the server&quot; 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&#39;s the config I&#39;m using. It&#39;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 &quot;!DBURL!mysql://ser:heslo@localhost/ser!g&quot;<br>
#!substdef &quot;!MY_IP_ADDR!192.168.0.148!g&quot;<br>
#!substdef &quot;!MY_WS_PORT!80!g&quot;<br>
#!substdef &quot;!MY_WSS_PORT!443!g&quot;<br>
#!substdef &quot;!MY_WS_ADDR!tcp:MY_IP_ADDR:MY_WS_PORT!g&quot;<br>
#!substdef &quot;!MY_WSS_ADDR!tls:MY_IP_ADDR:MY_WSS_PORT!g&quot;<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=&quot;<a href="http://example.com" target="_blank">example.com</a>&quot;<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=&quot;modules_k:modules&quot;<br>
#!else<br>
mpath=&quot;/usr/local/kamailio/lib/kamailio/modules_k/:/usr/local/kamailio/lib/kamailio/modules/&quot;<br>
#!endif<br>
<br>
loadmodule &quot;db_mysql.so&quot;<br>
loadmodule &quot;tm.so&quot;<br>
loadmodule &quot;sl.so&quot;<br>
loadmodule &quot;rr.so&quot;<br>
loadmodule &quot;pv.so&quot;<br>
loadmodule &quot;maxfwd.so&quot;<br>
loadmodule &quot;usrloc.so&quot;<br>
loadmodule &quot;registrar.so&quot;<br>
loadmodule &quot;textops.so&quot;<br>
loadmodule &quot;siputils.so&quot;<br>
loadmodule &quot;xlog.so&quot;<br>
loadmodule &quot;sanity.so&quot;<br>
loadmodule &quot;ctl.so&quot;<br>
loadmodule &quot;auth.so&quot;<br>
loadmodule &quot;auth_db.so&quot;<br>
loadmodule &quot;kex.so&quot;<br>
loadmodule &quot;mi_rpc.so&quot;<br>
#!ifdef WITH_TLS<br>
loadmodule &quot;tls.so&quot;<br>
#!endif<br>
#!ifdef WITH_WEBSOCKETS<br>
loadmodule &quot;xhttp.so&quot;<br>
loadmodule &quot;websocket.so&quot;<br>
loadmodule &quot;nathelper.so&quot;<br>
#!endif<br>
<br>
# ----------------- setting module-specific parameters ---------------<br>
<br>
# ----- tm params -----<br>
# auto-discard branches from previous serial forking leg<br>
modparam(&quot;tm&quot;, &quot;failure_reply_mode&quot;, 3)<br>
# default retransmission timeout: 30sec<br>
modparam(&quot;tm&quot;, &quot;fr_timer&quot;, 30000)<br>
# default invite retransmission timeout after 1xx: 120sec<br>
modparam(&quot;tm&quot;, &quot;fr_inv_timer&quot;, 120000)<br>
<br>
# ----- rr params -----<br>
# add value to ;lr param to cope with most of the UAs<br>
modparam(&quot;rr&quot;, &quot;enable_full_lr&quot;, 1)<br>
# do not append from tag to the RR (no need for this script)<br>
modparam(&quot;rr&quot;, &quot;append_fromtag&quot;, 0)<br>
<br>
# ----- registrar params -----<br>
modparam(&quot;registrar&quot;, &quot;method_filtering&quot;, 1)<br>
modparam(&quot;registrar&quot;, &quot;max_expires&quot;, 3600)<br>
modparam(&quot;registrar&quot;, &quot;gruu_enabled&quot;, 0)<br>
<br>
# ----- usrloc params -----<br>
modparam(&quot;usrloc&quot;, &quot;db_url&quot;, &quot;DBURL&quot;)<br>
modparam(&quot;usrloc&quot;, &quot;db_mode&quot;, 0)<br>
<br>
# ----- auth_db params -----<br>
modparam(&quot;auth_db&quot;, &quot;db_url&quot;, &quot;DBURL&quot;)<br>
modparam(&quot;auth_db&quot;, &quot;calculate_ha1&quot;, yes)<br>
modparam(&quot;auth_db&quot;, &quot;password_column&quot;, &quot;password&quot;)<br>
modparam(&quot;auth_db&quot;, &quot;load_credentials&quot;, &quot;&quot;)<br>
<br>
#!ifdef WITH_TLS<br>
# ----- tls params -----<br>
modparam(&quot;tls&quot;, &quot;config&quot;, &quot;/usr/local/kamailio/etc/kamailio/tls.cfg&quot;)<br>
#!endif<br>
<br>
#!ifdef WITH_WEBSOCKETS<br>
# ----- nathelper params -----<br>
modparam(&quot;nathelper|registrar&quot;, &quot;received_avp&quot;, &quot;$avp(RECEIVED)&quot;)<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&#39;t be needed in the future if Kamailio and the<br>
                # WebSocket client support Outbound and Path.<br>
                force_rport();<br>
                if (is_method(&quot;REGISTER&quot;))<br>
                        fix_nated_register();<br>
                else {<br>
                        if (!add_contact_alias()) {<br>
                                xlog(&quot;L_ERR&quot;, &quot;Error aliasing contact &lt;$ct&gt;\n&quot;);<br>
                                sl_send_reply(&quot;400&quot;, &quot;Bad Request&quot;);<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(&quot;CANCEL&quot;)) {<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(&quot;Route&quot;);<br>
        if (is_method(&quot;INVITE&quot;))<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(&quot;484&quot;,&quot;Address Incomplete&quot;);<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(&quot;10&quot;)) {<br>
                sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>
                exit;<br>
        }<br>
<br>
        if(!sanity_check(&quot;1511&quot;, &quot;7&quot;)) {<br>
                xlog(&quot;Malformed SIP message from $si:$sp\n&quot;);<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 == &quot;&quot;) {<br>
                                if (!handle_ruri_alias()) {<br>
                                        xlog(&quot;L_ERR&quot;, &quot;Bad alias &lt;$ru&gt;\n&quot;);<br>
                                        sl_send_reply(&quot;400&quot;, &quot;Bad Request&quot;);<br>
                                        exit;<br>
                                }<br>
                        }<br>
#!endif<br>
                        route(RELAY);<br>
                } else {<br>
                        if ( is_method(&quot;ACK&quot;) ) {<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(&quot;404&quot;,&quot;Not here&quot;);<br>
                }<br>
                exit;<br>
        }<br>
}<br>
<br>
# Handle SIP registrations<br>
route[REGISTRAR] {<br>
        if (is_method(&quot;REGISTER&quot;)) {<br>
                if (!save(&quot;location&quot;))<br>
                        sl_reply_error();<br>
<br>
                exit;<br>
        }<br>
}<br>
<br>
# USER location service<br>
route[LOCATION] {<br>
        if (!lookup(&quot;location&quot;)) {<br>
                $var(rc) = $rc;<br>
                t_newtran();<br>
                switch ($var(rc)) {<br>
                        case -1:<br>
                        case -3:<br>
                                send_reply(&quot;404&quot;, &quot;Not Found&quot;);<br>
                                exit;<br>
                        case -2:<br>
                                send_reply(&quot;405&quot;, &quot;Method Not Allowed&quot;);<br>
                                exit;<br>
                }<br>
        }<br>
}<br>
<br>
# Authentication route<br>
route[AUTH] {<br>
        if (is_method(&quot;REGISTER&quot;) || from_uri==myself) {<br>
                # authenticate requests<br>
                if (!auth_check(&quot;$fd&quot;, &quot;subscriber&quot;, &quot;1&quot;)) {<br>
                        auth_challenge(&quot;$fd&quot;, &quot;0&quot;);<br>
                        exit;<br>
                }<br>
                # user authenticated - remove auth header<br>
                if(!is_method(&quot;REGISTER&quot;))<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 &amp;&amp; uri!=myself) {<br>
                sl_send_reply(&quot;403&quot;,&quot;Not relaying&quot;);<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&#39;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 &amp;&amp; $Rp != MY_WSS_PORT) {<br>
                xlog(&quot;L_WARN&quot;, &quot;HTTP request received on $Rp\n&quot;);<br>
                xhttp_reply(&quot;403&quot;, &quot;Forbidden&quot;, &quot;&quot;, &quot;&quot;);<br>
                exit;<br>
        }<br>
<br>
        xlog(&quot;L_DBG&quot;, &quot;HTTP Request Received\n&quot;);<br>
<br>
        if ($hdr(Upgrade)=~&quot;websocket&quot;<br>
                        &amp;&amp; $hdr(Connection)=~&quot;Upgrade&quot;<br>
                        &amp;&amp; $rm=~&quot;GET&quot;) {<br>
                xlog(&quot;L_DBG&quot;, &quot;WebSocket\n&quot;);<br>
                xlog(&quot;L_DBG&quot;, &quot; Host: $hdr(Host)\n&quot;);<br>
                xlog(&quot;L_DBG&quot;, &quot; Origin: $hdr(Origin)\n&quot;);<br>
<br>
                if ($hdr(Host) == $null || !is_myself($hdr(Host))) {<br>
                        xlog(&quot;L_WARN&quot;, &quot;Bad host $hdr(Host)\n&quot;);<br>
                        xhttp_reply(&quot;403&quot;, &quot;Forbidden&quot;, &quot;&quot;, &quot;&quot;);<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(&quot;404&quot;, &quot;Not found&quot;, &quot;&quot;, &quot;&quot;);<br>
}<br>
<br>
event_route[websocket:closed] {<br>
        xlog(&quot;L_INFO&quot;, &quot;WebSocket connection from $si:$sp has closed\n&quot;);<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>