Hi All,
for days I’m trying to setup asterisk inside docker-compose. I was able to create environment connect it to trunk but no audio on inbound/outbound calls. Between local peers I have audio but call drops after some time with similar warning for retransmission. I understand that problem is with configuring asterisk to work with NAT settings but I don’t know what else to do.
I don’t have much experience with setting up asterisk, so I really need help with this.
Environment is hosted on AWS instance so trunk and all peers are outside the local network.
Here is my setup:
docker-compose.yml
version: "3.7"
services:
asterisk:
build: ./asterisk/
restart: always
# environment:
# ASTERISK_UID: 501
# ASTERISK_GID: 20
# ASTERISK_UID: "id -u"
# ASTERISK_GID: "id -g"
ports:
- 5060:5060/udp
- 5060:5060/tcp
- 10000-10050:10000-10050/udp
# network_mode: host
# privileged: true
depends_on:
- postgres
entrypoint: /wait-for-it.sh postgres:5432 --
command: /docker-entrypoint.sh
volumes:
- ./asterisk/volumes/sounds:/var/lib/asterisk/sounds
- ./asterisk/volumes/keys:/var/lib/asterisk/keys
- ./asterisk/volumes/phoneprov:/var/lib/asterisk/phoneprov
- ./asterisk/volumes/spool:/var/spool/asterisk
- ./asterisk/volumes/logs:/var/log/asterisk
- ./asterisk/config/sip.conf:/etc/asterisk/sip.conf
- ./asterisk/config/queues.conf:/etc/asterisk/queues.conf
- ./asterisk/config/extensions.conf:/etc/asterisk/extensions.conf
- ./asterisk/config/cdr.conf:/etc/asterisk/cdr.conf
- ./asterisk/config/cdr_pgsql.conf:/etc/asterisk/cdr_pgsql.conf
- ./asterisk/config/rtp.conf:/etc/asterisk/rtp.conf
- ./asterisk/config/pjsip.conf:/etc/asterisk/pjsip.conf
postgres:
build: ./postgres/
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_PASSWORD: 123123
POSTGRES_DB: asterisk
volumes:
- postgres-volume:/var/lib/postgresql/data
volumes:
postgres-volume:
name: asterisk-postgres-volume
sip.conf
[general]
context=public ; Default context for incoming calls. Defaults to 'default'
allowoverlap=no ; Disable overlap dialing support. (Default is yes)
udpbindaddr=0.0.0.0 ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
tcpenable=no ; Enable server for incoming TCP connections (default is no)
tcpbindaddr=0.0.0.0 ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
transport=transport-udp-nat ; Set the default transports. The order determines the primary default transport.
srvlookup=yes ; Enable DNS SRV lookups on outbound calls
qualify=yes
direct_media=no
rtp_symmetric=yes
force_rport=yes
nat=force_rport,comedia
;localnet=10.0.0.0/255.0.0.0
;localnet=192.168.0.0/255.255.0.0
;externip=18.214.49.215
;107.22.170.158
;register => ******:*****XGPxCE@us-east-va.sip.flowroute.com
;allow=ulaw
[authentication]
[basic-options](!) ; a template
dtmfmode=rfc2833
context=from-office
type=friend
[natted-phone](!,basic-options) ; another template inheriting basic-options
directmedia=no
host=dynamic
[public-phone](!,basic-options) ; another template inheriting basic-options
directmedia=yes
[my-codecs](!) ; a template for my preferred codecs
disallow=all
allow=ilbc
allow=g729
allow=gsm
allow=g723
allow=ulaw
[ulaw-phone](!) ; and another one for ulaw-only
disallow=all
allow=ulaw
[flowroute]
type=friend
secret=*********
username=****8709
host=us-east-va.sip.flowroute.com
dtmfmode=rfc2833
context=incoming
canreinvite=no
allow=ulaw
insecure=port,invite
fromdomain=us-east-va.sip.flowroute.com
[agent1]
type=friend
context=phones
allow=ulaw,alaw
secret=123123
host=dynamic
;nat=yes
[agent2]
type=friend
context=phones
allow=ulaw,alaw
secret=123123
host=dynamic
;nat=yes
[agent3]
type=friend
context=phones
allow=ulaw,alaw
secret=123123
host=dynamic
;nat=yes
pjsip.conf
[transport-udp-nat]
type=transport
protocol=udp
;bind=0.0.0.0
localnet=10.0.0.0/255.0.0.0
localnet=192.168.0.0/255.255.0.0
;external_media_address=127.0.0.1
;external_signaling_address=127.0.0.1
;type=transport
;protocol=udp
;bind=0.0.0.0
;local_net=192.168.65.0/24
;external_media_address=host.docker.internal
;external_signaling_address=host.docker.internal
external_media_address=18.214.49.215
external_signaling_address=18.214.49.215
extensions.conf
[general]
[globals]
AREACODE=
;Enter a local 3-digit area code here
TECHPREFIX=****8709*
;Populate only if IP-based authentication is desired, you’ll need to
;whitelist your IP as well. You must use an eight-digit format, followed by an
;asterix (*)—12345678*.
[outgoing]
exten => _1NXXNXXXXXX,1,Dial(SIP/${TECHPREFIX}${EXTEN}@flowroute)
exten => _NXXNXXXXXX,1,Dial(SIP/${TECHPREFIX}1${EXTEN}@flowroute)
exten => _NXXXXXX,1,Dial(SIP/${TECHPREFIX}1${AREACODE}${EXTEN}@flowroute)
exten => _011.,1,Dial(SIP/${TECHPREFIX}${EXTEN:3}@flowroute)
[incoming]
exten => 12013714710,1,Goto(phones,103,1)
[phones]
exten => 101,1,NoOp(First Line)
same => n,Dial(Sip/agent1)
same => n,Hangup
exten => 102,1,NoOp(First Line)
same => n,Dial(Sip/agent3)
same => n,Hangup
exten => 103,1,NoOp(First Line)
same => n,Dial(Sip/agent3)
same => n,Hangup
exten => _1NXXNXXXXXX,1,Goto(outgoing,${EXTEN},1)
Log:
asterisk_1 | [Oct 6 07:42:13] NOTICE[66]: chan_sip.c:24708 handle_response_peerpoke: Peer 'flowroute' is now Reachable. (1ms / 2000ms)
asterisk_1 | [Oct 6 07:42:16] -- Registered SIP 'agent1' at 192.168.224.1:60099
asterisk_1 | [Oct 6 07:42:16] -- Registered SIP 'agent3' at 192.168.224.1:60099
asterisk_1 | [Oct 6 07:42:17] NOTICE[66]: chan_sip.c:24708 handle_response_peerpoke: Peer 'agent1' is now Reachable. (130ms / 2000ms)
asterisk_1 | [Oct 6 07:42:17] NOTICE[66]: chan_sip.c:24708 handle_response_peerpoke: Peer 'agent3' is now Reachable. (131ms / 2000ms)
asterisk_1 | [Oct 6 07:42:46] == Using SIP RTP CoS mark 5
asterisk_1 | [Oct 6 07:42:46] -- Executing [15854570651@phones:1] Goto("SIP/agent3-00000000", "outgoing,15854570651,1") in new stack
asterisk_1 | [Oct 6 07:42:46] -- Goto (outgoing,15854570651,1)
asterisk_1 | [Oct 6 07:42:46] -- Executing [15854570651@outgoing:1] Dial("SIP/agent3-00000000", "SIP/83758709*15854570651@flowroute") in new stack
asterisk_1 | [Oct 6 07:42:46] == Using SIP RTP CoS mark 5
asterisk_1 | [Oct 6 07:42:46] -- Called SIP/****8709*15854570651@flowroute
asterisk_1 | [Oct 6 07:42:48] -- SIP/flowroute-00000001 is ringing
asterisk_1 | [Oct 6 07:42:48] -- SIP/flowroute-00000001 is making progress passing it to SIP/agent3-00000000
asterisk_1 | [Oct 6 07:43:12] -- SIP/flowroute-00000001 answered SIP/agent3-00000000
asterisk_1 | [Oct 6 07:43:12] -- Channel SIP/flowroute-00000001 joined 'simple_bridge' basic-bridge <18b42844-82cf-476f-bea7-01f126211907>
asterisk_1 | [Oct 6 07:43:12] -- Channel SIP/agent3-00000000 joined 'simple_bridge' basic-bridge <18b42844-82cf-476f-bea7-01f126211907>
asterisk_1 | [Oct 6 07:43:20] WARNING[66]: chan_sip.c:4072 retrans_pkt: Retransmission timeout reached on transmission nVSrySim9xRuDC-fSdbn8nsu83Zn2U3A for seqno 11771 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
asterisk_1 | Packet timed out after 8385ms with no response
asterisk_1 | [Oct 6 07:43:20] WARNING[66]: chan_sip.c:4096 retrans_pkt: Hanging up call nVSrySim9xRuDC-fSdbn8nsu83Zn2U3A - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
asterisk_1 | [Oct 6 07:43:20] -- Channel SIP/agent3-00000000 left 'native_rtp' basic-bridge <18b42844-82cf-476f-bea7-01f126211907>
asterisk_1 | [Oct 6 07:43:20] == Spawn extension (outgoing, 15854570651, 1) exited non-zero on 'SIP/agent3-00000000'
asterisk_1 | [Oct 6 07:43:20] -- Channel SIP/flowroute-00000001 left 'native_rtp' basic-bridge <18b42844-82cf-476f-bea7-01f126211907>
asterisk_1 | [Oct 6 07:43:52] == Using SIP RTP CoS mark 5
asterisk_1 | [Oct 6 07:43:52] -- Executing [103@phones:1] NoOp("SIP/agent1-00000002", "First Line") in new stack
asterisk_1 | [Oct 6 07:43:52] -- Executing [103@phones:2] Dial("SIP/agent1-00000002", "Sip/agent3") in new stack
asterisk_1 | [Oct 6 07:43:52] == Using SIP RTP CoS mark 5
asterisk_1 | [Oct 6 07:43:52] -- Called Sip/agent3
asterisk_1 | [Oct 6 07:43:52] -- SIP/agent3-00000003 is ringing
asterisk_1 | [Oct 6 07:43:52] -- SIP/agent3-00000003 is ringing
asterisk_1 | [Oct 6 07:43:54] -- SIP/agent3-00000003 answered SIP/agent1-00000002
asterisk_1 | [Oct 6 07:43:54] -- Channel SIP/agent3-00000003 joined 'simple_bridge' basic-bridge <f3e76222-d877-4be6-9afe-c979c3b93b86>
asterisk_1 | [Oct 6 07:43:54] -- Channel SIP/agent1-00000002 joined 'simple_bridge' basic-bridge <f3e76222-d877-4be6-9afe-c979c3b93b86>
asterisk_1 | [Oct 6 07:44:03] WARNING[66]: chan_sip.c:4072 retrans_pkt: Retransmission timeout reached on transmission BQ.5lH4lAOhZh0jdbRxXcwXLsmVg8Syh for seqno 10611 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
asterisk_1 | Packet timed out after 8320ms with no response
asterisk_1 | [Oct 6 07:44:03] WARNING[66]: chan_sip.c:4096 retrans_pkt: Hanging up call BQ.5lH4lAOhZh0jdbRxXcwXLsmVg8Syh - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
asterisk_1 | [Oct 6 07:44:03] -- Channel SIP/agent1-00000002 left 'native_rtp' basic-bridge <f3e76222-d877-4be6-9afe-c979c3b93b86>
asterisk_1 | [Oct 6 07:44:03] -- Channel SIP/agent3-00000003 left 'native_rtp' basic-bridge <f3e76222-d877-4be6-9afe-c979c3b93b86>
asterisk_1 | [Oct 6 07:44:03] == Spawn extension (phones, 103, 2) exited non-zero on 'SIP/agent1-00000002'
Thank you all!!!