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 :


register => *number1*:*password1*@*domain.ovh1*:5060~1800


callerid="Guillaume" <200>


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



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

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) :

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:
    -- 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
       > 0x7fddc0007570 -- Strict RTP learning complete - Locking on source address
**[Dec 30 11:14:51] WARNING[102621]: chan_sip.c:4119 retrans_pkt: Retransmission timeout reached on transmission 21e57c21411ca1f84ab8847365025d45@ for seqno 103 (Critical Request) -- See**
**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@ - no reply to our critical packet (see**
    -- 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,") in new stack
    -- Launched AGI Script /usr/share/asterisk/agi-bin/atmos-request.agi
 atmos-request.agi, MEUHHHHHH
    -- <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:

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.


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.


After that I got the same result.


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

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


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 :
My Wifi IP :

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


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 :

register =>

New pjsip.conf :

protocol=udp    ;udp,tcp,tls,ws,wss

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

Old sip.conf


new pjsip.conf



**Sections for my softphone on android **

old sip.conf

callerid="Guillaume" <200>

new pjsip.conf



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;branch=z9hG4bK7b0aab7d
Via: SIP/2.0/UDP;branch=z9hG4bK47fba0c5

Corrected sip.conf:


(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.