As a continuation of my project, I am trying to set up Kamailio as a Websocket bridge to
Asterisk. The asterisk instance is running as localhost, with its own websocket support
disabled, but otherwise has accounts with all of the avfp and dtls settings for
websockets. Additionally, I have removed the bindaddr=127.0.0.1 from sip.conf and instead
put a deny=0.0.0.0/0.0.0.0 and permit=127.0.0.1/255.255.255.0 in order to restrict SIP
signaling to localhost. This allows asterisk to bypass rtpproxy when signaling
through a websocket. I have already established calls originating from the browser.
However, I have an issue with the registration.
In my setup, Kamailio receives the REGISTER from whatever source, and forwards this
through UDP to Asterisk, after the multiple-domain transformation. Therefore, Asterisk
sees the following in its SIP port (all traffic through localhost):
REGISTER
sip:pbx.villacis.com SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bKc1c5.cb49f656197d0ba16f2a1661dd6a44cc.0
Via: SIP/2.0/WSS
r01r0mla9hdp.invalid;rport=47307;received=192.168.3.2;branch=z9hG4bK9309681
Max-Forwards: 69
To: <sip:avillacisIM_pbx.villacis.com@127.0.0.1:5080>
From: "Alex Villac..s"
<sip:avillacisIM_pbx.villacis.com@127.0.0.1:5080>;tag=b5c0lq4kac
Call-ID: vp2akar0aqfmgfa6m1taau
CSeq: 82 REGISTER
Contact:
<sip:fnuql6ft@192.168.3.2:47307;transport=ws>;reg-id=1;+sip.instance="<urn:uuid:6b0c58ee-bdc5-47c0-aff0-963132dc0cad>";expires=600
Allow: ACK,CANCEL,BYE,OPTIONS,INFO,NOTIFY,INVITE,MESSAGE
Supported: path,gruu,outbound
User-Agent: SIP.js/0.6.2
Content-Length: 0
Asterisk answers this through UDP, and Kamailio forwards it through the websocket:
SIP/2.0 200 OK
Via: SIP/2.0/UDP
127.0.0.1;branch=z9hG4bKc1c5.cb49f656197d0ba16f2a1661dd6a44cc.0;received=127.0.0.1;rport=5060
Via: SIP/2.0/WSS
r01r0mla9hdp.invalid;rport=47307;received=192.168.3.2;branch=z9hG4bK9309681
From: "Alex Villac..s"
<sip:avillacisIM_pbx.villacis.com@127.0.0.1:5080>;tag=b5c0lq4kac
To: <sip:avillacisIM_pbx.villacis.com@127.0.0.1:5080>;tag=as5ae2df76
Call-ID: vp2akar0aqfmgfa6m1taau
CSeq: 82 REGISTER
Server: Asterisk PBX 11.12.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH,
MESSAGE
Supported: replaces, timer
Expires: 600
Contact: <sip:fnuql6ft@192.168.3.2:47307;transport=ws>;expires=600
Date: Thu, 28 Aug 2014 22:21:15 GMT
Content-Length: 0
Then Asterisk sends this through UDP, and Kamailio again forwards it through the
websocket:
NOTIFY sip:fnuql6ft@192.168.3.2:47307;transport=ws SIP/2.0
Via: SIP/2.0/UDP 127.0.0.1:5080;branch=z9hG4bK4d60f167;rport
Max-Forwards: 70
From: "asterisk" <sip:asterisk@127.0.0.1:5080>;tag=as43c12840
To: <sip:fnuql6ft@192.168.3.2:47307;transport=ws>
Contact: <sip:asterisk@127.0.0.1:5080>
Call-ID: 04deeb0068a847fa514d748c7d9993c5@127.0.0.1:5080
CSeq: 102 NOTIFY
User-Agent: Asterisk PBX 11.12.0
Event: message-summary
Content-Type: application/simple-message-summary
Content-Length: 89
Messages-Waiting: no
Message-Account: sip:*97@127.0.0.1:5080
Voice-Message: 0/0 (0/0)
Since I have not implemented handling of voicemail indications, the browser answers this:
SIP/2.0 405 Method Not Allowed
Via: SIP/2.0/UDP 127.0.0.1:5080;branch=z9hG4bK4d60f167;rport=5080
To: <sip:fnuql6ft@192.168.3.2:47307;transport=ws>;tag=ggu5etber9
From: "asterisk" <sip:asterisk@127.0.0.1:5080>;tag=as43c12840
Call-ID: 04deeb0068a847fa514d748c7d9993c5@127.0.0.1:5080
CSeq: 102 NOTIFY
Supported: outbound
Content-Length: 0
After that, Asterisk wants to send an OPTIONS packet. From the point of view of Asterisk
(sip set debug on), it is already sent, but never gets a response. However, tcpdump shows
that the packet is never sent through the localhost interface in the first
place. It is also not sent through any other interface. My guess is that since the
REGISTER has a contact with transport=ws , Asterisk wants to send this through a websocket
(which is disabled). So I could have to generate a contact without transport=ws .
I have worked around this by setting qualify=no in the account for the websocket, but I
would like a better solution, one that allows the OPTIONS packet to reach the browser, and
to get the response. What is the proper way to deal with this?