Help pleasešŸ™‚Calls hang up randomly, but almost every time now

Hello every one, Iā€™m new to Asterisk but I read a lot of documentation and setup my own asterisk server.
Iā€™m french so I hope you can understand my english :grinning_face_with_smiling_eyes:

below, italic value are replaced with real values of course but as itā€™s password or login I donā€™t show them here :

*number1* : the call number of the SIP line (provider : OVH)
*password1* : the password of the line
*domain.ovh1* : the OVH domain
*PORT* : port number
*userpassword* : the password for the user

First : my settings :

SIP.CONF

[general]
nat=comedia
;defaultexpiry=1800
;rtautoclear=no
context=atmos-default-context
bindport=*PORT*
bindaddr=0.0.0.0
srvlookup=no
register => *number1*:*password1*@*domain.ovh1*:5060~1800
disallow=all
allow=ulaw
allow=alaw
qualify=yes


[atmos-default-context]
type=friend
host=*domain.ovh1*
context=atmos
language=fr
insecure=invite,port
username=*number1*
secret=*password1*


[Guillaume]
secret=*userpassword*
callerid="Guillaume" <200>
context=local
mailbox=200@default
type=peer
host=dynamic

USERS.CONF

Just the default one, provided when Asterisk is installed. I added my users in sip.conf (only 1 user : [Guillaume])

EXTENSIONS.CONF

[general]
static=yes
writeprotect=no
autofallthrough=yes
clearglobalvars=no
priorityjumping=no

[atmos-outgoing-calls]
exten => _0[1-5]XXXXXXXX,1,Dial(SIP/${EXTEN}@atmos-default-context)
exten => _09XXXXXXXX,1,Dial(SIP/${EXTEN}@atmos-default-context)

[atmos]
exten => s,1,Set(ATMOS_CONTEXT=START)
same => n,Set(ATMOS_INPUT=-)
same => n,Goto(atmos-server-query,s,1)

and other extensions that are working fine usually.
And of course the extension that redirect the call to a user (always Guillaume of course since itā€™s the only one now) :

[atmos-pick-up]
exten => s,1,Verbose("PickUp avec ${AQR_DIALSIP} pour une durƩe de ${AQR_DELAY}")
same => n,Dial(${AQR_DIALSIP},${AQR_DELAY})
same => n,Goto(atmos-server-query,s,1)
exten => h,1,Goto(atmos-caller-hangup,s,1)

**Devices : **

The Asterisk Server is hosted on a VPS hosted by IONOS, directly connected to the internet (no nat and the firewall is only blocking port 22 for ssh access).

Only Asterisk is installed on this server, no other server or applications.

User Guillaume is receiving the calls on an android softphone : PortSIP UC

Sometimes eveything is working fine, but very often :

**The problem **

Someone is calling the SIP number
the softphone is ringing
Guillaume answer and can chat, the sound is working well for both sides
After few seconds, between 7 and 30 seconds usually, the call hang up by itself
When it hangup, the call for the caller hangups, and for the softphone, it continues running but no sound of course since it stopped on the caller side.

Here the log when the call is transmitted to the softphone :
I put in bold what is the problem according to me :

Executing [s@atmos-pick-up:2] Dial("SIP/atmos-default-context-0000018c", "SIP/Guillaume,60") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/Guillaume
    -- SIP/Guillaume-0000018d is ringing
    -- SIP/Guillaume-0000018d is ringing
       > 0x7fddc0007570 -- Strict RTP learning after remote address set to: 82.66.71.140:10196
    -- SIP/Guillaume-0000018d answered SIP/atmos-default-context-0000018c
    -- Channel SIP/Guillaume-0000018d joined 'simple_bridge' basic-bridge <d746d666-9be8-4f2e-9c17-40086b82f7c2>
    -- Channel SIP/atmos-default-context-0000018c joined 'simple_bridge' basic-bridge <d746d666-9be8-4f2e-9c17-40086b82f7c2>
       > Bridge d746d666-9be8-4f2e-9c17-40086b82f7c2: switching from simple_bridge technology to native_rtp
       > Remotely bridged 'SIP/atmos-default-context-0000018c' and 'SIP/Guillaume-0000018d' - media will flow directly between them
       > 0x7fddc0007570 -- Strict RTP qualifying stream type: audio
       > 0x7fddc0007570 -- Strict RTP switching source address to 82.66.71.140:35251
       > 0x7fddc0007570 -- Strict RTP learning complete - Locking on source address 82.66.71.140:35251
**[Dec 30 11:14:51] WARNING[102621]: chan_sip.c:4119 retrans_pkt: Retransmission timeout reached on transmission 21e57c21411ca1f84ab8847365025d45@82.165.120.235:16060 for seqno 103 (Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions**
**Packet timed out after 6400ms with no response**
**[Dec 30 11:14:51] WARNING[102621]: chan_sip.c:4143 retrans_pkt: Hanging up call 21e57c21411ca1f84ab8847365025d45@82.165.120.235:16060 - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).**
    -- Channel SIP/Guillaume-0000018d left 'native_rtp' basic-bridge <d746d666-9be8-4f2e-9c17-40086b82f7c2>
    -- Channel SIP/atmos-default-context-0000018c left 'native_rtp' basic-bridge <d746d666-9be8-4f2e-9c17-40086b82f7c2>
  == Spawn extension (atmos-pick-up, s, 2) exited non-zero on 'SIP/atmos-default-context-0000018c'
    -- Executing [h@atmos-pick-up:1] Goto("SIP/atmos-default-context-0000018c", "atmos-caller-hangup,s,1") in new stack
    -- Goto (atmos-caller-hangup,s,1)
    -- Executing [s@atmos-caller-hangup:1] AGI("SIP/atmos-default-context-0000018c", "atmos-request.agi,https://atmos-app.clangen.com:5218/asterisk-call/q/5f4158f90327605b58e922aa/060f7191f0fc4d0eae4c164221c46d1e/hangup/START/0671760272/s/1640862873.683/-") in new stack
    -- Launched AGI Script /usr/share/asterisk/agi-bin/atmos-request.agi
 atmos-request.agi,https://atmos-app.clangen.com:5218/asterisk-call/q/5f4158f90327605b58e922aa/060f7191f0fc4d0eae4c164221c46d1e/hangup/START/0671760272/s/1640862873.683/-: MEUHHHHHH
 atmos-request.agi,https://atmos-app.clangen.com:5218/asterisk-call/q/5f4158f90327605b58e922aa/060f7191f0fc4d0eae4c164221c46d1e/hangup/START/0671760272/s/1640862873.683/-: https://atmos-app.clangen.com:5218/asterisk-call/q/5f4158f90327605b58e922aa/060f7191f0fc4d0eae4c164221c46d1e/hangup/START/0671760272/s/1640862873.683/-
 atmos-request.agi,https://atmos-app.clangen.com:5218/asterisk-call/q/5f4158f90327605b58e922aa/060f7191f0fc4d0eae4c164221c46d1e/hangup/START/0671760272/s/1640862873.683/-:
    -- <SIP/atmos-default-context-0000018c>AGI Script atmos-request.agi completed, returning 0

Of course I read the documentation on the url provided in the log, but I donā€™t understand what to do now.
The serveur is hosted on a dedicated server, there is nothing blocking RTP port.

the softphone can be either connected via Wifi (behind an internet box, so behind a nat), or via 4G, and the problem can occur in both situation (the provided log was generated by a test when the softphone is on Wifi).


Do someone see something bad in my sip.conf or extensions.conf that could create this issue ?
Did I forget something important ?

Can my softphone be the problem ?
Is there a recommanded softphone for Android ?

Any help would be welcome iā€™m lost.
Thank you so much :slight_smile: and thank you for reading !

This should be pjsip.conf, for a new installation, with appropriate changes in the configuration language.

Please read the description of username:

https://github.com/asterisk/asterisk/blob/master/configs/samples/sip.conf.sample#L110

Most likely you need fromuser.

Are you really sure you need insecure=port? Same for nat=comedia.

None of these should cause random failures, so you need to provide sip set debug on output for failing and successful calls.

Normally this is a NAT problem (typically failing to specify your external address), but the sequence number makes me think this is a re-invite, which suggest that the ITSP has a broken implementation of Re-INVITEs, which ignores them rather than, at least, returning a failure response.

It is generally unlikely that direct media will work well with ITSPs, so you should disable that.

Hello,

Thank you for the fast answer, I tried to follow your suggestions.
Here what I did and what I got :

PJSIP instead of SIP
I renamed sip.conf to pjsip.conf, but then I was unable to make Asterisk work normally, even the ā€œsip show registryā€ returned : no such command. So finally I renamed again to sip.conf

**[atmos-default-context] **

I changed this section like this :

I removed the PORT in insecure
I removed username and password from this section.

[atmos-default-context]
type=friend
host=sbc5.fr.sip.ovh
context=atmos
language=fr
insecure=invite

After that I got the same result.

NAT=COMEDIA

I removed this parameter (NAT=comedia). But I got no audio when my android softphone is on Wifi behind a NAT, but itā€™s working when iā€™m on 4G. During the test, the problem happened on Wifi, but not on 4G. (as it sometimes happens randomly on Wifi / 4G, I canā€™t be sure).

So I restored NAT=COMEDIA to get back audio on Wifi.

I did 3 tests in Wifi, 3 in 4G, and no bug from now.
But it often happens that after I restart the server many times the problem dissapear, and after few hours or days it happens again more and more often.

So as itā€™s not happening currently I couldnā€™t try with sip set debug on but as soon as it happens again I will do it and send the log.

chan_pjsip is a new driver, with a new configuration file format. chan_sip is not included by default in current versions and will soon be removed completely. Bugs in chan_sip are very unlikely to get fixed.

nat=comedia is a work around for defective peers. If I understand it, this should only be applied to the defective soft phone, not globally. In any case it seems you have a complex network topology and details are essential.

Do you have NAT with an unstable public address? chan_pjsip has support for refreshing IP addresses from dynamic DNS, but unstable addresses are never desirable.

Tahank you for the details, so If I understood :

  1. My asterisk is too old as it uses chan_sip and sip.conf instead of chan_pjsip and pjsip.conf ? And I should configure it with pjsip.conf ? how to do that ?

  2. I will move NAT=comedia to user Guillaume instead as general configuration

  3. The IP address of the server is always the same, it doesnā€™t change. For my Android softphone, on Wifi, the IP is always the same.

Of course on my phone the IP can change if I turn on / off wifi and use 4G instead of Wifi.

You started by saying you were new to Asterisk. That implies you started using it long after chan_pjsip became the preferred channel driver, for SIP. All currently supported versions include chan_pjsip.

Okay so maybe I found tutorial and documentation that explains how to use it with chan_sip instead of pjsip.

As iā€™m new, I even didnā€™t know there are 2 differents drivers :smiley:

Is there a kind of ā€œmigrationā€ tutorial somewhere to change my configuration to use chan_pjsip instead of chan_sip ?

This page might be of some help to you
https://wiki.asterisk.org/wiki/display/AST/Migrating+from+chan_sip+to+res_pjsip

Most tutorials on chan_sip are flawed, so it is best to try and configure from first principles.

Hello,

Sorry for the delay I was sick little bit these last days.
As you requested, I turned on sip set debug on.

I tried a call and it was fine, so here the log I got with sip debug on
(I called using my android softphone on wifi behind a NAT at home) :

Server IP is : 82.165.120.235
My Wifi IP : 82.66.71.140

asterisk debug log on - success call (softphone-wifi).txt (77.4 KB)

I will try again and when i call fails, I will post the log in another message here.

Note : this test is done with sip.conf

Hi,

I tried to switch from sip.conf to pjsip.conf, I tried to follow the doc to convert my settings, so now here what I did :

I renamed sip.conf to sip.conf.old
I created pjsip.conf in the same directory as sip.conf.old (/etc/asterisk)

I will show you the ā€œoldā€ sip.conf and the ā€œnewā€ pjsip.conf.

Please can you tell me whatā€™s wrong because nothing is working anymore at all.

**General Section **

Old sip.conf :

[general]
nat=comedia
;defaultexpiry=1800
;rtautoclear=no
context=atmos-default-context
bindport=16060
bindaddr=0.0.0.0
srvlookup=no
register => 0033972665115:password_ovh@sbc5.fr.sip.ovh:5060~1800
disallow=all
allow=ulaw
allow=alaw
qualify=yes

New pjsip.conf :

[transport-udp]
type=transport
protocol=udp    ;udp,tcp,tls,ws,wss
bind=0.0.0.0
SERVER_PORT=10060

**Sections to connect to the OVH SIP Provider (to receive calls) **

Old sip.conf

[atmos-default-context]
type=friend
host=sbc5.fr.sip.ovh
context=atmos
language=fr
insecure=invite

new pjsip.conf

[atmos-default-context]
type=registration
transport=transport-udp
outbound_auth=atmos-default-context_auth
server_uri=sip:sbc5.fr.sip.ovh
client_uri=sip:0033972665115@sbc5.fr.sip.ovh
contact_user=0033972665115
retry_interval=60
forbidden_retry_interval=600
expiration=1800
line=yes
endpoint=atmos-default-context

[atmos-default-context_auth]
type=auth
auth_type=userpass
password=password_ovh
username=0033972665115
realm=sbc5.fr.sip.ovh

**Sections for my softphone on android **

old sip.conf

[Guillaume]
secret=userpassword
callerid="Guillaume" <200>
context=local
mailbox=200@default
type=peer
host=dynamic

new pjsip.conf

[Guillaume]
type=endpoint
transport=transport-udp
context=from-internal
disallow=all
allow=ulaw
auth=200
aors=200
direct_media=no
rtp_symmetric=yes
force_rport=yes

[Guillaume]
type=auth
auth_type=userpass
password=userpassword
username=200

Then I saved the pjsip.conf and started asterisk : service asterisk start

And I tried : asterisk -rvvv

and I tried to type : sip show registry to check if it registered, but it shows :

localhost*CLI> sip show registry
No such command 'sip show registry' (type 'core show help sip show' for other possible commands)

and also :

pjsip show registrations
No objects found.

and I checked on the OVH website, it didnā€™t register.

Could you help me to check this file ?
Thank you so much

Hello again, this morning I could catch a call that dropped after 8 seconds (hangup from called side, continue with no sound on softphone for a moment and after a while hangup too.

Here is the log (same configuration, same server, same wifi as the one who succeeded yesterday in the previous success log.

asterisk debug log on - failed call (dropped after around 8 seconds) (softphone-wifi).txt (87.6 KB)

I hope this log can help :slight_smile:

look like the a branch issue

Via: SIP/2.0/UDP 82.165.120.235:16060;branch=z9hG4bK7b0aab7d
Via: SIP/2.0/UDP 82.165.120.235:16060;branch=z9hG4bK47fba0c5

Corrected sip.conf:

[atmos-default-context]
type=peer
host=sbc5.fr.sip.ovh
context=atmos
language=fr

(insecure=invite is meaningless without a secret. I donā€™t believe that they really set their from user to ā€œastmos-default-contextā€ and call you from a different address, so type=friend is just a security loophole.)

In pjsip.conf add endpoint, aor and idnentify sections. Also the definition of transport-udp. For the phone, add type=aor section.

Branch issue ?
What can I do to fix it ?

is there anything between the phones and asterisk (GW/Firewall/ā€¦) that could be messing with the headers, like SIP ALG

There is nothing. The wifi is from the internet box from the internet carrier. It has no firewall included. It only has a DHCP server to provide ip address to my phone and other devices.

The server is directly connected on the internet, no nat.

I also get this problem sometimes when I receive calls directly on 4G.

The call is failing on the Portsip side, not the OVH side. It is ignoring, rather than honouring or rejecting an attempt to re-INVITE to direct media. Iā€™ve seen this failure in some free soft phones.

So the trouble can come from my softyphone ? Iā€™m using PortSIP UC on Android. Do you have a softphone on android to recommand ? Iā€™m ready to try another one if thatā€™s the problem.