ARI fails to process large http requests. Asterisk 16

Asterisk 16.2.1

So I am trying to send large http request to ARI (that is still under 4096 bits) to originate a call. Http request contain large body with lots of SIP headers and SIP body that needs to be set.
When I send such a request from chrome using ARI swagger there is no issues, call originated as expected. But when I try to do it from my java app using ari4java library or even appache http client it fails with:

“WARNING[9145]: http.c:923 http_body_read_contents: Short HTTP request body (Wanted 2890)”

After some wiresharking and looking in http.c source code I believe the issue here is in the way asterisk http server process incoming http requests.
For example if I send request from chrome, http client in chrome manage to break requests in TCP segments the way that http headers are delivered in separate segment and body of the message in subsequent segments. And it looks like that is exactly what asterisk http server is expecting to get.
But in case of java client http request is broken the way that http headers and part of body are delivered together in same first TCP segment. In this case asterisk http server doesn’t bother to look in buffer for rest of the message and treat that first segment as entire message and fail because length in “Content-Length” http header doesn’t match the length of part of http body in that first segment.

@jcolp @david551 can you please let me know if I got it wrong and if there is any work around for this issue?

Thank you!

Here is some wireshark results to better understand what I am talking about:

Http request from java app (failed)

Http request through ARI swagger UI from chrome (succeed)

Http request through ARI swagger UI from chrome (succeed)

Please don’t tag specific people. If we have anything of value to add or wish to respond we will do so.


I have to take my “TCP segments” theory back because this behavior is not consistent. Sometimes request from swagger fails as well (no changes to request) and sometimes request from java app (using ari4java library or appache http client) goes through (again no changes to request). But requests from java app still fails most of the time with:

http.c:923 http_body_read_contents: Short HTTP request body (Wanted 3601)

Any ideas?

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