PJSIP realtime - Call hangup after 30 seconds

I have done one setup below:
I have installed one Kamailio server and two Asterisk servers. Asterisks are configured with PJSIP realtime and PJSIP realtime users are getting registered with Kamailio IP Fine. Calls are coming fine to the both Asterisk servers with dispatcher module and working good with audio both sides. SIP users are registered with Kamailio IP and media service is working on Asterisk.

The issue I am facing randomly is some calls are getting auto hangup after 30 seconds.

My Call Pattern: 102 → INVITE → KAMAILIO → ASTERISK → Play hello world → Dial(PJSIP/kamtrunk/sip:101@KAMAILIO_IP:5060) → Rings 101 → Answer call

I have given sngrep trace images for both error call and working call below.
Error Call:

Working Call:

I assume problem happens during dialing endpoint back to Kamailio from Asterisk dialplan as per mentioned above Dial string. In that case I am not sure WHY it sends multiple 200 OK even it acknowledges it already. Call is established and both side audio working but after 30 seconds call hangup. This happens randomly. I am using Zoiper as softphone.

You need to show actual SIP trace from Asterisk itself using “pjsip set logger on”. In general though it means the ACK did not arrive, or it was invalid in some way.

I am sharing pjsip log in details as below.

The 200 OK is coming from via UDP. The Contact header in it is port 47114 using TCP. Asterisk is sending the ACK to the location specified in the Contact header. It’s presumably not able to connect / send. If that traffic is supposed to go through the proxy then you need to use record routing.

Now I am using UDP in Kamailio and Asterisk both side. Also I kept like below in Kamailio for INVITE request.


Now, I am testing and checking with multiple calls to reproduce the issue. Thanks for your reply!! I will share more testing results if needed.

Hi jcolp,
The changes above worked for me and call working fine. Thanks for the help. I have one more setup in that Asterisk and Kamailio both are on same server. Below is call flow.

Call Setup: 102 → INVITE → KAMAILIO → ASTERISK → Play hello world → Dial(PJSIP/kamtrunk/sip:101@ → Rings 101 → Answer call

Asterisk is at : (
Kamailio is at : (

I have given link for PJSIP call log in detail as below:

Here I am facing issue of no voice from either end of softphone and also call auto hangup after 30 seconds.

Please check the logs above and help me what I am doing wrong. Thanks.

I would suggest looking at the logs yourself, the IP addresses, where traffic is going, seeing if that’s correct or not. These are skills you need if you are using Asterisk and Kamailio.

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