Getting randomly 400 Bad request on INVITE

I am using Asterisk 16.2.1 version.
Randomly I get SIP 400 Bad request message from Asterisk whenever trying to make new call. The previous call has ended in controlled manner, and next one opens nicely again.

The error message coming with it is: “399 SIP “Invalid value or argument (PJ_EINVAL)””

Any idea where this could be coming from? Apparently the SDP validation fails for some reason, but I don’t see what is the difference between valid and invalid requests. The only difference between successful and failed SDP contents are Session ID and Session version.

An example of a failed message content:

v=0
o=user1 1646382819 1646382819 IN IP4 10.40.4.40
s=-
c=IN IP4 10.40.4.40
t=0 0
m=audio 50644 RTP/AVP 9 101
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv

The full SIP message would need to be shown. You’re also running an old version of 16.

An example of failed INVITE:

INVITE sip:PA.Z0011.V0.P1.C100000@10.40.4.136 SIP/2.0
Call-ID: 6567844c19b384121d2762442b6a0eed@10.40.4.40
CSeq: 27 INVITE
From: <sip:2222@10.40.4.40:38839>;tag=z6JMk0SU
To: <sip:PA.Z0011.V0.P1.C100000@10.40.4.136>
Via: SIP/2.0/UDP 10.40.4.40:38839;branch=z9hG4bK-393336-dc5a6eaaae1bbbb216d36f37588ca0e6
Max-Forwards: 70
Contact: <sip:2222@10.40.4.40:38839>
Content-Type: application/sdp
Content-Length: 175

v=0
o=user1 1646382868 1646382868 IN IP4 10.40.4.40
s=-
c=IN IP4 10.40.4.40
t=0 0
m=audio 50644 RTP/AVP 9 101
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv

An example of successful INVITE:

INVITE sip:PA.Z0011.V0.P1.C100000@10.40.4.136 SIP/2.0
Call-ID: 156b631d6f895bc2a98c646d5ac90579@10.40.4.40
CSeq: 26 INVITE
From: <sip:2222@10.40.4.40:38839>;tag=Mo4jYE0a
To: <sip:PA.Z0011.V0.P1.C100000@10.40.4.136>
Via: SIP/2.0/UDP 10.40.4.40:38839;branch=z9hG4bK-393336-b235138af06505e6e135f135ec37eeee
Max-Forwards: 70
Contact: <sip:2222@10.40.4.40:38839>
Content-Type: application/sdp
Content-Length: 175

v=0
o=user1 1646382819 1646382819 IN IP4 10.40.4.40
s=-
c=IN IP4 10.40.4.40
t=0 0
m=audio 50644 RTP/AVP 9 101
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv

The Bad request message:

SIP/2.0 400 Bad Request
Via: SIP/2.0/UDP 10.40.4.40:38839;rport=38839;received=10.40.4.40;branch=z9hG4bK-393336-dc5a6eaaae1bbbb216d36f37588ca0e6
Call-ID: 6567844c19b384121d2762442b6a0eed@10.40.4.40
From: <sip:2222@10.40.4.40>;tag=z6JMk0SU
To: <sip:PA.Z0011.V0.P1.C100000@10.40.4.136>;tag=z9hG4bK-393336-dc5a6eaaae1bbbb216d36f37588ca0e6
CSeq: 27 INVITE
Warning: 399 SIP "Invalid value or argument (PJ_EINVAL)"
Server: PBX
Content-Length:  0

There is nothing immediately evident.

Is it possible that there is something in the network that causes UDP package to be corrupted somehow?
This is a wireshark capture, not sure if it is reliable compared to what has been received actually.
But the error message on Asterisk logs is referring to validating the SDP content - what the code tries to do where this error message is thrown? Could Asterisk be in congestion or somehow overloaded and therefore not capable of handling all requests as expected?

It’s coming from PJSIP itself, so it would be somewhere in PJSIP and not Asterisk. I don’t know specifically.

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