### Description When calling the async_route() from event_route[xhttp:request], an error occurs.
ERROR: tm [t_lookup.c:769]: t_lookup_request(): too few headers ERROR: async [async_sleep.c:238]: async_sleep(): cannot create the transaction
#### Reproduction The problem is reproducible. Below is a fragment of the configuration file. ... listen=tcp:192.168.3.115:8080 loadmodule "xhttp.so" loadmodule "async.so" ...
event_route[xhttp:request] { async_route("TEST", "2"); exit; }
route[TEST] { xhttp_reply("200", "OK", "text/html", "<html><body>URL $hu</body></html>\r\n"); exit; }
Making a HTTP-request:
curl -X POST http://192.168.3.115:8080/test \ -H "Content-Type: application/json" \ -d '{"test": 1}'
#### Log Messages
[messages.zip](https://github.com/kamailio/kamailio/files/13994226/messages.zip)
### Additional Information
#kamailio -v version: kamailio 5.7.3 (x86_64/linux) e4d96b flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: e4d96b compiled on 12:59:36 Nov 17 2023 with gcc 4.8.5
* **Operating System**:
#cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core)
Closed #3720 as completed.
Questions about using or configuring kamailio has to be addressed to sr-users@lists.kamailio.org mailing list. The tracker is for reporting issues in the C code.
Hi, @miconda! Unfortunately, you are wrong. The problem is in the Kamailio source files. The xhttp module, having received an http-packet, creates a fake sip_msg that does not pass validation in t_lookup.c. This worked in earlier versions of Kamailio. If you are interested in solving the problem, then I ask you to re-open the issue and analyze it.
If you read the first line of the first chapter in the docs of the async module you understand it is not any bug in the code. For discussing more, use the mailing list as suggested.
The problem is in the xhttp module. The fake_msg generated by it no longer pass Kamailio's internal validation. I am sure that the problem will also appear when calling other functions that make a copy of the sip-package and validate it.
@miconda, the problem with sip-message validation can be get round by using this strange configuration and http-request:
``` event_route[xhttp:request] { **$ru = "sip:1@127.0.0.1";** async_route("TEST", "2"); } route[TEST] { xhttp_reply("200", "OK", "text/plain", "URL $hu\r\n"); exit; } ```
``` # cat ./test.sh curl -X POST http://192.168.3.115:8080/test \ -H "Content-Type: application/json" \ **-H "From: sip:1@127.0.0.1" \ -H "To: sip:2@127.0.0.1" \ -H "CSeq: 1 POST" \ -H "Call-ID: qwerty" ** -d '{"test": 1} ```
You need to rewrite R-URI and add fields From, To, CSeq and Call-ID to prevent package validation. I think, correction R-RURI and adding the required headers must be done when creating fake_msg. What do you think?
https://www.kamailio.org/docs/modules/stable/modules/async.html#idm20:
This module provides asynchronous operations for handling **SIP** requests in the configuration file.
Yes, and the xhttp module converts the received http-request into sip and add the Via header to it. The xhttp module makes a fake sip message to be able to use functions from other modules. 
I have prepared and tested a patch to fix the problem. It is applied to the `xhttp_mod.c` file. [patch.txt](https://github.com/kamailio/kamailio/files/14001353/patch.txt)