OpenSIPS / opensips

OpenSIPS is a GPL implementation of a multi-functionality SIP Server that targets to deliver a high-level technical solution (performance, security and quality) to be used in professional SIP server platforms.
https://opensips.org
Other
1.22k stars 570 forks source link

[BUG] HTTPD do not properly process fragmented HTTP packets #3350

Open kertor opened 3 months ago

kertor commented 3 months ago

OpenSIPS version you are running

version: opensips 3.4.4 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, HP_MALLOC, DBG_MALLOC, FAST_LOCK-FUTEX-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll, sigio_rt, select.
git revision: de6fcb66b
main.c compiled on  with gcc 9

Describe the bug

HTTPD lib on OpenSIPS do not work properly in case, when it receive fragmented HTTP request.

My HTTPD module settings:

########################################################################
loadmodule "httpd.so"
########################################################################
modparam("httpd", "port", 8001)
modparam("httpd", "buf_size", 1048576)

########################################################################
loadmodule "mi_http.so"
########################################################################

When i use system command curl, like:

curl -X POST "HOST:8001/mi" -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"get_statistics","params":[["all"]],"id":1}'

then all works like a charm (OpenSIPS quickly return response), because OpenSIPS receive not fragmented HTTP packet: curl



But, if i use opensips-cli , then i have incorrect behavior: opensips-cli just stuck, because there is no response from OpenSIPS. Please look at this screenshot:

opensips-cli

As you can see, python3 lib (which use opensips-cli ) send json content in separate packet ("2 reassembled TCP Segments"). When OpenSIPS receive it, it stucks and can not return response.

To Reproduce

Explained above - on my system these libs installed:

apt list --installed | grep -E 'opensips-cli|http'

libhttp-date-perl/focal,now 6.05-1 all [installed,automatic]
libhttp-message-perl/focal,now 6.22-1 all [installed,automatic]
libmicrohttpd-dev/now 0.9.77-1 amd64 [installed,local]
libmicrohttpd12/now 0.9.77-1 amd64 [installed,local]
libnghttp2-14/focal-updates,focal-security,now 1.40.0-1ubuntu0.2 amd64 [installed,automatic]
opensips-cli/focal,now 0.1~20231129~79d721d-1 all [installed,automatic]
opensips-http-modules/focal,now 3.4.4~20240319~de6fcb66b-1 amd64 [installed,automatic]
python3-httplib2/focal,now 0.14.0-1ubuntu1 all [installed,automatic]

To avoid this problem with slow OpenSIPS response, in our Python3 scripts we use this fix to avoid HTTP packets splitting:

+from requests.packages.urllib3.connection import HTTPConnection
+HTTPConnection.default_socket_options = [(6,3,1)]

Expected behavior

OpenSIPS can process: 1) not fragmented HTTP packets; 2) fragmented HTTP packets.

Relevant System Logs

OS/environment information

Additional context

github-actions[bot] commented 2 months ago

Any updates here? No progress has been made in the last 15 days, marking as stale. Will close this issue if no further updates are made in the next 30 days.

kertor commented 2 months ago

UP

github-actions[bot] commented 2 months ago

Any updates here? No progress has been made in the last 15 days, marking as stale. Will close this issue if no further updates are made in the next 30 days.

github-actions[bot] commented 1 month ago

Marking as closed due to lack of progress for more than 30 days. If this issue is still relevant, please re-open it with additional details.

nikbyte commented 1 month ago

up

github-actions[bot] commented 3 weeks ago

Any updates here? No progress has been made in the last 15 days, marking as stale. Will close this issue if no further updates are made in the next 30 days.

kertor commented 3 weeks ago

Up

github-actions[bot] commented 1 week ago

Any updates here? No progress has been made in the last 15 days, marking as stale. Will close this issue if no further updates are made in the next 30 days.