Fritzbox does not receive calls after upgrading to pjsip

After upgrading from chan_sip to res_pjsip the Fritzbox SIP client doesn’t receive calls anymore. Unfortunately the Fritzbox doesn’t offer any logging so I’ve resorted to inspecting network traffic. The Fritzbox responds to the INVITE message with a 400 Bad Request reply. I don’t know if this is because pjsip doesn’t include the port (I’ve configured Fritzbox to use port 15060 so Asterisk can use 5060 for traffic that goes through the Fritzbox) or because the message body doesn’t have media or attribute lines with pjsip. Is there a way to add this information with res_pjsip?

This is the SIP trafffic for res_pjsip:

INVITE sip:fritzbox@192.168.178.1:15060;uniq=B4354203A778B5ACB3F5803B620B2 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.2:5060;rport;branch=z9hG4bKPj08a2ee50-1500-41d5-a728-55cd340568d8
From: <sip:120@192.168.0.2>;tag=e0ec016b-0568-4fde-bb65-7cc7d84c2a3e
To: <sip:fritzbox@192.168.178.1;uniq=B4354203A778B5ACB3F5803B620B2>
Contact: <sip:asterisk@192.168.0.2:5060>
Call-ID: dc8589e6-fbad-4bf0-abe0-ca9a53771717
CSeq: 19646 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 19.6.0
Content-Type: application/sdp
Content-Length:    94

v=0
o=- 1120785675 1120785675 IN IP4 192.168.0.2
s=Asterisk
c=IN IP4 192.168.0.2
t=0 0


SIP/2.0 400 Bad Request
Via: SIP/2.0/UDP 192.168.0.2:5060;rport=5060;branch=z9hG4bKPj08a2ee50-1500-41d5-a728-55cd340568d8;received=192.168.178.101
From: <sip:120@192.168.0.2>;tag=e0ec016b-0568-4fde-bb65-7cc7d84c2a3e
To: <sip:fritzbox@192.168.178.1;uniq=B4354203A778B5ACB3F5803B620B2>;tag=badrequest
Call-ID: dc8589e6-fbad-4bf0-abe0-ca9a53771717
CSeq: 19646 INVITE
User-Agent: FRITZ!OS
Content-Length: 0

With chan_sip, the INVITE packet reads:

INVITE sip:fritzbox@192.168.178.1:15060;uniq=B4354203A778B5ACB3F5803B620B2 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.2:5060;branch=z9hG4bK5d0406f0;rport
Max-Forwards: 70
From: "User A" <120@192.168.0.2>;tag=as1140e6c9
To: <sip:fritzbox@192.168.179.1:15060;uniq=B4354203A778B5ACB3F5803B620B2>
Contact: <sip:101@192.168.0.2:5060>
Call-ID: 282b0c8a292ff3046b2c295427313c18@192.168.0.2:5060
CSeq: 102 INVITE
User-Agent: Asterisk PBX 13.18.3~dfsg-1ubuntu4
Date: Wed, 07 Sep 2022 19:40:32 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 299

v=0
o=root 355309722 355309722 IN IP4 192.168.0.80
s=Asterisk PBX 13.18.3~dfsg-1ubuntu4
c=IN IP4 192.168.0.80
t=0 0
m=audio 10220 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

What is the PJSIP endpoint? Are you using “allow=all”? If so, don’t do that. Specify your codecs. Your version of Asterisk causes the INVITE to not contain full SDP information.

1 Like

Thank you so much, it was allow=all. By specifying codecs, media and attribute lines are added to the INVITE body and the Fritzbox accepts the call.

The SIP endpoint is the Fritzbox. It has a built-in ATA with a connected POTS phone.

This is the INVITE after specifying codecs:

INVITE sip:fritzbox@192.168.178.1:15060;uniq=B4354203A778B5ACB3F5803B620B2 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.2:5060;rport;branch=z9hG4bKPj3c727d58-8547-404b-8417-7f80a87e5dd3
From: <sip:120@192.168.0.2>;tag=d4cb0aa1-8c38-427e-a216-8ca0d6147e9b
To: <sip:fritzbox@192.168.178.1;uniq=B4354203A778B5ACB3F5803B620B2>
Contact: <sip:asterisk@192.168.0.2:5060>
Call-ID: 27f1d2dc-3d78-42f2-b1b9-63090492d24d
CSeq: 21389 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 19.6.0
Content-Type: application/sdp
Content-Length:   308

v=0
o=- 1779136605 1779136605 IN IP4 192.168.0.2
s=Asterisk
c=IN IP4 192.168.0.2
t=0 0
m=audio 15234 RTP/AVP 8 9 18 101
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrec