JsSSIP and Asterisk SIP

Hi ! I would like to create a phone app with flutter using dart sip_ua ( = jssip). So my UASettings are :

Map<String, String> _wsExtraHeaders = {
‘Origin’: ‘(* http://xxx.xx.xx.xxx’*),
‘Host’: ‘xxx.xxxxxxxx.com:8088
};

settings.webSocketUrl =  ("ws://xxx..xx.xx.xxx:8088/ws");
settings.uri = ("sip:xxx@xxxxxxxx.com");
settings.password = "******";
settings.dtmfMode = DtmfMode.INFO;
settings.webSocketSettings.extraHeaders = _wsExtraHeaders;

_helper.start(settings);

My web sockets is working, the connection is established but the server send me a 401 sip code and a 403 sip code (unauthorized then forbidden). I don’t know why because Asterisk 11 support WebSockets and I enabled http server. I’m using FreePBX GUI to configure asterisk file. My password and username are good. Someone can help me ? Thanks !

FreePBX does a lot more than configure Asterisk. It provides a lot of dialplan code, on which its configuration depends. Consequently, you need to ask in a place that understands FreePBX, e.g. https://community.freepbx.org/

I imagine they will require the details of the configuration of your channel driver (chan_pjsip, or possibly chan_sip).

Thank you for your reply ! I asked my question on FreePBX forum without response for the moment.
Now I can see that my res_http_websocket module isn’t on my module list. It faded away for no reason, and when I try to add it, this don’t work. I can’t see it in module list with cli command “module show like http” for example .

I can add it but it’s not enable …

with “http show status”, “/ws => Asterisk HTTP WebSocket” is missing in URI’s …
I really need it to enable webRTC, how can I add or activate this module ?

You asked in the developer section, when this appears to be a user question, and you didn’t provide details of your configuration. I notice there is another question about jsSSIP, which might be relevant.

Try manually loading it from the CLI. If that fails, the messages should give clues to the reason. If it succeeds, that suggests that modules.conf isn’t set to load it, or it trying to load it before one of its dependencies.

A module can fail to load because the module is missing (e.g. not built), it was built for the wrong version, it requires configuration and the configuration is missing or invalid, noload was specified, autoload was not specified and it wasn’t explicitly loaded, or was loaded before its dependencies, or one of its dependencies failed to load.

I moved it to Development on auto-pilot since generally anything to do with JsSIP is really developer level. I moved it out to Configuration based on the new information here.

Oh ok, i will fix that

Thx for you reply , I tried but I don’t see any commands in order to add some module when I use “core show help” … Do you know why or what is it ?

module load – Load a module by name

I fixed the problem, I already tried that but it seems that I have to add it with FreePBX GUI. Now I’m returning with the socket problem ahah. I’m trying to read server’s log

Ok, I’m not so far of the solution.

I can see here that it don’t recognize ws transport. But, in settings, I add it. Furthermore, I don’t know why it using chan_sip channel and not pjsip_sip channel. My settings are “using both”. What can I have to do more ??

What does this mean? I suspect this is yet another artefact of using FreePBX. Note that only one of chan_sip and chan_pjsip can actually bind to an IP address/socket combination.

You still haven’t provided your configuration (which for this forum is the contents of the .conf files, or, but more difficult to handle, the contents of the ARA database tables.

The module is part of Asterisk, not FreePBX, so it will have no knowledge of the FreePBX GUI. If you are forced to use that GUI, that is because of your general use of FreePBX, and is why you got redirected to the FreePBX forum.

PS Please provide log fragments (and configuration files) as pre-formatted text, copied from, preferably the log file, and failing that, the terminal emulator, not as images of screen content.

Thank you a lot for you answers ! I’m sorry I’m a new user
Do you mean that I have to select one ? chan_pjsip for instance ? On FreePBX GUI there is an option “both”, we can still select chan_sip or chan_pjsip. Now I’m not using FreePBX GUI, I’m on the virtual machine with linux.

pjsip.conf :

[global]
type=global
user_agent=FPBX-14.0.13.23(13.18.4)
default_outbound_endpoint=duma_endpoint

[0.0.0.0-udp]
type=transport
protocol=udp
bind=0.0.0.0:5160
external_media_address=178.33.26.237
external_signaling_address=178.33.26.237
allow_reload=yes

[0.0.0.0-tcp]
type=transport
protocol=tcp
bind=0.0.0.0:5160
external_media_address=178.33.26.237
external_signaling_address=178.33.26.237
allow_reload=yes

[0.0.0.0-tls]
type=transport
protocol=tls
bind=0.0.0.0:5161
external_media_address=178.33.26.237
external_signaling_address=178.33.26.237
allow_reload=yes

[0.0.0.0-ws]
type=transport
protocol=ws
bind=0.0.0.0
external_media_address=178.33.26.237
external_signaling_address=178.33.26.237
allow_reload=yes

[0.0.0.0-wss]
type=transport
protocol=wss
bind=0.0.0.0
external_media_address=178.33.26.237
external_signaling_address=178.33.26.237
allow_reload=yes

[dpma_endpoint]
type=endpoint
context=dpma-invalid


; I added this because I followed the asterisk's auto on setup webrtc, it is a example.

[199]
type=aor
max_contacts=1
remove_existing=yes
 
[199]
type=auth
auth_type=userpass
username=199
password= 199 ; This is a completely insecure password.  Do NOT expose this 
;               system to the Internet without utilizing a better password.

[199]
type=endpoint
aors=199
auth=199
use_avpf=yes
media_encryption=dtls
dtls_ca_file=/etc/asterisk/keys/ca.crt
dtls_cert_file=/etc/asterisk/keys/asterisk.pem
dtls_verify=fingerprint
dtls_setup=actpass
ice_support=yes
media_use_received_transport=yes
rtcp_mux=yes
context=default
disallow=all
allow=opus
allow=law

sip.conf :

accept_outofcall_message=yes
auth_message_requests=no
outofcall_message_context=dpma_message_context
faxdetect=no
vmexten=*97
useragent=FPBX-14.0.13.23(13.18.4)
disallow=all
allow=ulaw
allow=alaw
allow=gsm
allow=g726
allow=g722
allow=h264
allow=vp8
allow=h261
allow=h263p
allow=h263
context=from-sip-external
callerid=Unknown
notifyringing=yes
notifyhold=yes
tos_sip=cs3
tos_audio=ef
tos_video=af41
alwaysauthreject=yes
limitonpeers=yes
rtpend=20000
context=diese-context
rtpstart=10000
tcpenable=yes
callevents=yes
bindport=5060
jbenable=no
checkmwi=10
maxexpiry=3600
minexpiry=60
srvlookup=yes
tlsenable=no
allowguest=yes
notifyhold=yes
rtptimeout=30
canreinvite=no
t38pt_udptl=yes,redundancy,maxdatagram=400
tlsbindaddr=[::]:5061
rtpkeepalive=0
videosupport=yes
defaultexpiry=120
notifyringing=yes
maxcallbitrate=384
rtpholdtimeout=300
g726nonstandard=yes
registertimeout=20
tlsclientmethod=sslv2
registerattempts=0
nat=force_rport,comedia
ALLOW_SIP_ANON=no
callerid=Unknown
externip=178.33.26.237
language=fr

[aastra-check-cfg]
Event=>check-sync

[aastra-xml]
Event=>aastra-xml

[cisco-check-cfg]
Event=>check-sync

[cortelco-check-cfg]
Event=>check-sync

[digium-check-cfg]
Event=>check-sync

[grandstream-check-cfg]
Event=>check-sync

[htek-check-cfg]
Event=>check-sync

[linksys-cold-restart]
Event=>reboot_now

[linksys-warm-restart]
Event=>restart_now

[obihai-check-cfg]
Event=>sync

[polycom-check-cfg]
Event=>check-sync

[polycom-reboot]
Event=>check-sync

[sangoma-check-cfg]
Event=>check-sync

[sync-noreboot-sangoma]
Event=>check-sync\;reboot=false

[sync-reboot-sangoma]
Event=>check-sync\;reboot=true

[sync-hints-sangoma]
Event=>server_restart

[reboot-sangoma]
Event=>reboot

[sipura-check-cfg]
Event=>resync

[reboot-snom]
Event=>reboot

[spa-reboot]
Event=>reboot

[reboot-yealink]
Event=>check-sync\;reboot=true

;then users like 

[0766682888]
deny=0.0.0.0/0.0.0.0
disallow=all
secret=**************
dtmfmode=rfc2833
canreinvite=yes
context=diese-corntext
host=dynamic
defaultuser=
trustrpid=yes
sendrpid=pai
type=friend
session-timers=accept
nat=force_rport,comedia
port=5060
qualify=yes
qualifyfreq=60
transport=udp,tls
avpf=no
force_avp=no
icesupport=no
rtcp_mux=no
encryption=no
namedcallgroup=
namedpickupgroup=
allow=ulaw
allow=alaw
allow=gsm
dial=SIP/0766682888
permit=0.0.0.0/0.0.0.0
callerid=0766682888<0766682888>
callcounter=yes
faxdetect=no
cc_monitor_policy=generic
"

That is, is obviously, normally the sensible thing to do, given that they both implement the same protocol, and therefore compete for the same default ports. New installations should normally only use chan_pjsip.

Your sip.conf appears to be missing a section name, and has a lot of baggage from FreePBX, which makes it difficult to see what the significant options are. It is also setting the user agent to say it is FreePBX, which will cause confusion when viewed in logs. It contains some deprecated option names and, I think, it may also contain some bogus parameters, used by FreePBX, but not Asterisk.

allowguest=yes is not generally considered safe; the FreePBX dialplan has specific measures to mitigate that.

I’m not sure whether bind treats IPV4 wildcard and IPV6 wildcard addresses separately, but it looks like both are competing for port 5061.

Given that chan_sip is the one that ended up binding to the TLS port, you need to comply with the requirements in Home - Asterisk Documentation in order to use websockets. You comply with neither of them.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.