I’m running into an issue where Asterisk 16.0.1 will randomly reject SIP INVITE messages, claiming that the SDP contains invalid attributes. I say ‘randomly’ since my SIP clients always send INVITE messages with the same structure, but Asterisk only encounters problems parsing the SDP some of the time.
This problem occurs about 10% of the time when using the Speex codec, but I have also seen it happen with PCMA, albeit far less often. Asterisk responds with “400 Bad Request”. I have verified in Wireshark that the SIP/SDP of accepted and rejected INVITE messages are in fact identical (apart from dynamic elements such as the URI and ports, naturally). Speex SDP is attached. Could race conditions be at play? Is this a known issue?
I’m currently trying to find a way to reliably reproduce the issue. My program contains multiple SIP endpoints that attempt to call a ConfBridge conference at startup. The more clients I spin up, the more likely I am to encounter the issue.
Please provide the raw SDP, not wireshark’s interpretation of it. Also please provide the Asterisk debug log in sufficient detail to show which line is being rejected. (assuming chan_pjsip logs in similar detail to chan_sip).
Thanks for responding. Please find below the SDP for both a successful and a rejected INVITE. Note I removed the fmtp line after it made no difference to the behaviour.
Unfortunately, running Asterisk with verbose logging ‘asterisk -vvvvvvr’, provides no extra information with the error message than what I posted initially - that is, it doesn’t specify a line number or why is was rejected (same goes for /var/log/asterisk/messages).
I don’t seem to encounter the problem if I restart Asterisk before running my program, so perhaps Asterisk gets into some state during my program’s subsequent startups, during which time modules and config (pjsip, dialplan etc) are being reloaded.
I think you need both pjsip debug and debug level logging to see the detailed analysis. However I’ve only dealt with this sort of thing with chan_sip, so am not completely sure how much logging is available.
With ‘pjsip set logger on’, the following was all the information it gave me for one rejected SDP where my client was dialing into conference extension ‘9’ and establishing the media stream as ‘sendonly’ speex (though it happens with ‘sendrecv’ too). The line ‘a=fmtp:110 vbr=on;vbr=vad’ was just there for testing, but I confirmed it wasn’t affecting the rejection behaviour.
The logger output doesn’t seem to specify any more information unfortunately.
I also tried ‘logger set level DEBUG’ and ‘logger set level VERBOSE’ for the CLI, but that didn’t seem to have any effect…
You can also enable debugging directly from pjproject that could prove helpful. For instance, add something like the following to the pjproject.conf file (if you don’t have that file then create it wherever your other Asterisk conf files are located):
[startup]
type=startup
log_level=4
After restarting you should see more log data. It should output the line/column in the offending SDP.
Also if you are familiar with SIPp you might be able to use that to create a scenario that replicates the problem for faster testing.
Thanks for your advice. I updated my pjproject.conf file and discovered that my version of Asterisk 16 was compiled with a limited pjproject logging level, as shown by the error message below.
[Aug 8 15:36:16] WARNING[11437]: res_pjproject.c:529 load_module: Asterisk built or linked with pjproject PJ_LOG_MAX_LEVEL=3 which is too low for startup level: 4.
I’m currently rebuilding Asterisk with PJ_LOG_MAX_LEVEL=4, which should hopefully provide the extra ‘DEBUG’ level logging info I need to solve this issue. I’ll let you know once I have things up and running!
I’m having trouble finding where PJ_LOG_MAX_LEVEL=3 is defined in Asterisk/pjproject.
Initially I thought it was part of Asterisk options.h, but now it looks to be part of pjproject. The change log talks of how it was reduced from 6 to 2 to deal with some overwhelming logging from pjsua.
Would appreciate if anyone can point me in the right direction.
Are you building your own version of pjproject (i.e. not using bundled)?
The current bundled shows a max log level of 6 still.
This can be found and/or set in the pjlib/include/pj/config_site.h (from the pjproject source tree). For instance in the bundled version that comes with Asterisk it’s found in third-party/pjproject/source/pjlib/include/pj/config_site.h (from the Asterisk source tree)
More info can be found here about installing and building pjproject for asterisk. However it is recommended to use the bundled version that comes with Asterisk for the reasons given on that page.