Asterisk sending multiple invite during general call

I used Asterisk to call Client-B(pjsua) from Client-A(pjsua).

When I saw the flow I can see that Asterisk is sending a second INVITE to both Client-A and Client-B to establish the call. Shouldn’t the call establish right after Client-B gets the first INVITE and sends ACK ?

Also when Client-B sends BYE ; Asterisk is first sending an INVITE to Client-A before sending BYE the from Client-B. I am uploading my extensions.conf, pjsip.conf and my log file.
These are INVITE I am having trouble understanding.

1.Client-B second INVITE(Cseq12563)
2.Client-A getting an INVITE(Cseq23984) from Asterisk
3.Client-A getting an INVITE(Cseq23985) from Client-B via Asterisk after Client-B says BYE.

exten => 20001,1,Dial(PJSIP/20001,90)
exten => 20002,1,Dial(PJSIP/20002,90)

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




debug_log_rewrite_contact.txt (147.1 KB)

Re-INVITE for direct media, see:


Re-INVITE to undo direct media and restore Asterisk to media path.

1 Like

Thank you so much for your information. I have another question
can I do rtp transmission (peer to peer) with the re-invite Like shown in rfc 3665.

You can’t send INVITE to clients. I don’t know whether chan_pjsip can optimise the initial INVITE to the remote user agent server by including the direct media address in the original SDP, but the directrtpsetup option on chan_sip was never supported, so even with that, you do it at your own risk.

You will have to provide a more precise reference if you want me to find the example in the RFC.

1 Like
using only one proxy or
rfc3665 with 2 proxies
For Example’
Ter-A->(Cseq 1 INVITE)->Asterisk->(Cseq 1 INVITE)->Ter-B
Ter-A<-(Cseq 1 100 Trying)<-Asterisk
Ter-A<-(Cseq 1 180 Ringing)<-Asterisk<-(Cseq 1 Ringing)Ter-B
Ter-A<-(Cseq 1 200 OK)<-Asterisk<-(Cseq 1 200 OK)Ter-B
Ter-A->(Cseq 1 ACK)->Asterisk->(Cseq 1 ACK)->Ter-B

But in my case Re-Invite is required for direct rtp connection between terminals. I want to make a basic call with only one INVITE. Is direct media between peer-to-peer without re-invite achievable with Asterisk? Why this re-invite is coming in the 1st place?

Asterisk is a back to back user agent, not a proxy, so the two INVITEs on your first line are independent, and their CSEQ numbering is independent.

1 Like

I understand that Asterisk is a B2BUA not a proxy server even so is it possible to create a peer to peer RTP connection without the reinvite ?

No, it is not possible in PJSIP and as David stated the “directrtpsetup” option is unsupported in chan_sip.

1 Like

Thank you for your kind information. You really helped a lot. But I have a silly question. Is there any other way to achieve basic call flow of sip below:
Ter-A->(Cseq 1 INVITE)->Server->(Cseq 1 INVITE)->Ter-B
Ter-A<-(Cseq 1 100 Trying)<-Server
Ter-A<-(Cseq 1 180 Ringing)<-Server<-(Cseq 1 Ringing)Ter-B
Ter-A<-(Cseq 1 200 OK)<-Server<-(Cseq 1 200 OK)Ter-B
Ter-A->(Cseq 1 ACK)->Server->(Cseq 1 ACK)->Ter-B

Use a proxy.

Note the SIP protocol allows Ter-A → (Cseq 1 INVITE) → Ter-B, without an intermediary, although entering full SIP URIs through a phone keypad can be difficult, and good practice is probably to block such attempts on the UAS, to avoid direct calls from toll fraudsters.

It would probably help to know why you are spending such much time trying to achieve this.

Thank you so much for your help. Could you give me suggestions on using which proxy server. It would be better if the proxy server is free and open source.

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