Either outbound works or inbound works, but both doesn't work

This is my sip.conf

; inbound configuration

[nexmo-sip]
fromdomain=sip.nexmo.com
type=friend
context=nexmo
insecure=port,invite
nat=no
;Add your codec list here.
; Note: Use "ulaw" for US only, "alaw" for the rest of the world.
allow=ulaw
allow=alaw
allow=G729
dtmfmode=rfc2833

[nexmo-sip-01](nexmo-sip)
host=173.193.199.24

[nexmo-sip-02](nexmo-sip)
host=174.37.245.34

[nexmo-sip-03](nexmo-sip)
host=5.10.112.121

[nexmo-sip-04](nexmo-sip)
host=5.10.112.122

[nexmo-sip-05](nexmo-sip)
host=119.81.44.6

[nexmo-sip-06](nexmo-sip)
host=119.81.44.7

;outbound configuration

[general]
register => <api-key>:<api-secret>@sip.nexmo.com
registerattempts=0
srvlookup=yes  
context=nexmo-sip1

[nexmo]
username=<api-key>
host=sip.nexmo.com
defaultuser=<api-key>
fromuser=<myNumber123>  
fromdomain=sip.nexmo.com
secret=<api-secret>
type=friend
context=nexmo-sip1
insecure=very
qualify=yes
nat=no
;Add your codec list here.
; Note: Use "ulaw" for US only, "alaw" for the rest of the world.
allow=ulaw
allow=alaw
allow=G729
dtmfmode=rfc2833

[<myNumber123>]   ; this number is at soft phone client
type=friend
context=nexmo-sip1
host=dynamic
secret=<myNumber123>
qualify=yes

[<mynumber123456>]  ; this is my mobile number
type=friend
context=nexmo-sip1
host=dynamic
secret=<secretkey>
qualify=yes

This is extensions.conf

[general]
live_dangerously=yes
[globals]

[nexmo-sip1]

exten => _X.,1,Dial(SIP/${EXTEN}@nexmo)

[default]
exten => s,1,gosub(nexmo-sip1,${EXTEN},1)

Setting 1: If above is the setting of extensions.conf, I am able to make outbound calls from my soft client, but not able to get inbound calls to that soft client

Setting 2: If I change the settings of extensions.conf as follows, I am able to get incoming calls at softclient, but not able to make outbound calls.

[general]
live_dangerously=yes
[globals]

[nexmo-sip1]

exten => _X.,1,Dial(SIP/${EXTEN},30)

[default]
exten => s,1,gosub(nexmo-sip1,${EXTEN},1)

Question 1) What should I change so that I get both outbound and inbound calls?

Question 2: When I set extensions.conf as in Setting 1, I don’t hear the other side, but I hear both the side conversation when extensions.conf is set as in Setting 2. How to fix that? And this is the log I see when I don’t hear

[Jul 1 22:50:38] WARNING[11299]: chan_sip.c:4175 retrans_pkt: Retransmission timeout reached on transmission tvK9cRGNN- for seqno 21 (Critical Response) – See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 8383ms with no response
[Jul 1 22:50:38] WARNING[11299]: chan_sip.c:4204 retrans_pkt: Hanging up call tvK9cRGNN- - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).

I understand that there are lot of wrong configurations like insecure=very etc. But right now I want to make this prototype to work successfully

Put this in your extensions.conf file

[nexmo-sip1]

exten => _XXXXX.,1,Dial(SIP/${EXTEN}@nexmo)

[nexmo]

exten => _XXXXX.,1,Dial(SIP/nexmo-sip-01&SIP/nexmo-sip-02&SIP/nexmo-sip-03&SIP/nexmo-sip-04)

[default]
exten => s,1,gosub(nexmo-sip1,${EXTEN},1)

1 Like

Hi, Thanks for answering.

It doesn’t work. I mean outgoing working and incoming to softphone is not working

This is what I get

Connected to Asterisk 11.7.0~dfsg-1ubuntu1 currently running on ip-<SOME-IP>(pid = 11284)
  == Using SIP RTP CoS mark 5
    -- Executing [ <myNumber123>@nexmo-sip1:1] Dial("SIP/nexmo-sip-01-000000d6", "SIP/ <myNumber123>@nexmo") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/ <myNumber123>@nexmo
  == Using SIP RTP CoS mark 5
    -- Executing [ <myNumber123>@nexmo-sip1:1] Dial("SIP/nexmo-sip-01-000000d8", "SIP/ <myNumber123>@nexmo") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/ <myNumber123>@nexmo
  == Spawn extension (nexmo-sip1, <myNumber123>, 1) exited non-zero on 'SIP/nexmo-sip-01-000000d6'
  == Spawn extension (nexmo-sip1, <myNumber123>, 1) exited non-zero on 'SIP/nexmo-sip-01-000000d8'

There is a context=nexmo-sip1 in general context of sip.conf

I was following this tutorial http://www.open-voip.org/index.php?title=Asterisk_Inbound_%26_Outbound_with_your_SIP_provider in my case I have one virtual number which is MyNumber123 and one real mobile number

The way inbound call works is by configuring in nexmo.com to “forward to sip” and enter sip:MyNumber@MyAsteriskServer_Ip_Adrress

Post everything that you have in the sip.conf and extensions.conf files.

Sip.conf same as in my first post and extensions.conf as you said

sip.conf

;inbound configuration

[nexmo-sip]
fromdomain=sip.nexmo.com
type=friend
context=nexmo
insecure=port,invite
nat=no
;Add your codec list here.
; Note: Use "ulaw" for US only, "alaw" for the rest of the world.
allow=ulaw
allow=alaw
allow=G729
dtmfmode=rfc2833

[nexmo-sip-01](nexmo-sip)
host=173.193.199.24

[nexmo-sip-02](nexmo-sip)
host=174.37.245.34

[nexmo-sip-03](nexmo-sip)
host=5.10.112.121

[nexmo-sip-04](nexmo-sip)
host=5.10.112.122

[nexmo-sip-05](nexmo-sip)
host=119.81.44.6

[nexmo-sip-06](nexmo-sip)
host=119.81.44.7

;outbound configuration

[general]
register => <api-key>:<api-secret>@sip.nexmo.com
registerattempts=0
srvlookup=yes  
**context=nexmo-sip1**

[nexmo]
username=<api-key>
host=sip.nexmo.com
defaultuser=<api-key>
fromuser=<myNumber123>  
fromdomain=sip.nexmo.com
secret=<api-secret>
type=friend
context=nexmo-sip1
insecure=very
qualify=yes
nat=no
;Add your codec list here.
; Note: Use "ulaw" for US only, "alaw" for the rest of the world.
allow=ulaw
allow=alaw
allow=G729
dtmfmode=rfc2833

[<myNumber123>]   ; this number is at soft phone client
type=friend
context=nexmo-sip1
host=dynamic
secret=<myNumber123>
qualify=yes

[<mynumber123456>]  ; this is my mobile number
type=friend
context=nexmo-sip1
host=dynamic
secret=<secretkey>
qualify=yes

extensions.conf

'[general]
[globals]

[nexmo-sip1]

exten => _XXXXX.,1,Dial(SIP/${EXTEN}@nexmo)

[nexmo]

exten => _XXXXX.,1,Dial(SIP/nexmo-sip-01&SIP/nexmo-sip-02&SIP/nexmo-sip-03&SIP/nexmo-sip-04)

[default]
exten => s,1,gosub(nexmo-sip1,${EXTEN},1)

What are the nexmo-sip-0X in the sip.conf file?
Which is the number of your extension that you want to receive the calls?

What are the nexmo-sip-0X in the sip.conf file?
IN sip.conf

[nexmo-sip-01](nexmo-sip)
host=173.193.199.24

[nexmo-sip-02](nexmo-sip)
host=174.37.245.34

[nexmo-sip-03](nexmo-sip)
host=5.10.112.121

[nexmo-sip-04](nexmo-sip)
host=5.10.112.122

[nexmo-sip-05](nexmo-sip)
host=119.81.44.6

[nexmo-sip-06](nexmo-sip)
host=119.81.44.7

Which is the number of your extension that you want to receive the calls?

In sip.conf, I have like this

[12223334444]   ; this number is at soft phone client
type=friend
context=nexmo-sip1
host=dynamic
secret=12223334444
qualify=yes

[19998887777]  ; this is my mobile number
type=friend
context=nexmo-sip1
host=dynamic
secret=19998887777
qualify=yes

12223334444 is the one that should receive the call. I call from my mobile, it goes to nexmo and in nexmo for 12223334444, I have set “forward to sip : sip:12223334444@Public_IP_address_of_asterisk_Server”