### Description The ACK that response to 200 OK was NAT relayed by Kamailio if using TCP protocol, then got this issue from log ```pending write on new connection 0x14a595095d40 sock 16 (-1/539 bytes written) (err: 11 - Resource temporarily unavailable)```
<!-- Explain what you did, what you expected to happen, and what actually happened. -->
### Troubleshooting
#### Reproduction * Using KAMI with Lua for routing config. * make call between 2 sip clients, the receiver has been registered with TCP
#### Debugging Data * With the same scenario with UDP, it work fine. *
<!-- If you got a core dump, use gdb to extract troubleshooting data - full backtrace, local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile bt full info locals list
If you are familiar with gdb, feel free to attach more of what you consider to be relevant. -->
``` (paste your debugging data here) ```
#### Log Messages
<!-- Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). -->
``` Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <script>: ROUTE RELAY BEGIN:----------------------------------------------------------- Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: tm [t_lookup.c:1327]: t_newtran(): msg (0x14a5999f0b38) id=3/4784 global id=2/4784 T start=0xffffffffffffffff Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: tm [t_lookup.c:497]: t_lookup_request(): start searching: hash=41830, isACK=1 Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: tm [t_lookup.c:455]: matching_3261(): RFC3261 transaction matching failed - via branch [z9hG4bKQe8H61SrNcaXD] Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: tm [t_lookup.c:675]: t_lookup_request(): no transaction found Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: tm [t_funcs.c:286]: t_relay_to(): forwarding ACK statelessly Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <core> [core/crypto/md5utils.c:67]: MD5StringArray(): MD5 calculated: 66c47e5249a7009267e0cd264863c247 Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <core> [core/msg_translator.c:1797]: check_boundaries(): no multi-part body Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <core> [core/forward.c:577]: forward_request(): Sending:#012ACK sip:Joe%20Biden@14.186.XXX.XX:60791;transport=TCP SIP/2.0#015#012Via: SIP/2.0/TCP 188.166.XXX.XX:5060;branch=z9hG4bK663a.66c47e5249a7009267e0cd264863c247.0#015#012Via: SIP/2.0/UDP 127.0.0.2;received=127.0.0.2;rport=5060;branch=z9hG4bKQe8H61SrNcaXD#015#012Max-Forwards: 69#015#012From: "Donald Trump" sip:33123456789@127.0.0.2;tag=mUNavKm60XZte#015#012To: sip:5512345@127.0.0.3:5060;transport=udp;tag=bd21bf6b#015#012Call-ID: 0e846d85-720e-123a-45a5-ea0e9328da5f#015#012CSeq: 39612479 ACK#015#012Contac t: sip:gw+KamGW@127.0.0.2:5060;transport=udp;gw=KamGW#015#012Content-Length: 0#015#012#015#012. Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <core> [core/forward.c:578]: forward_request(): orig. len=557, new_len=539, proto=2 Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: app_lua [app_lua_api.c:489]: sr_lua_reload_script(): No need to reload [/path-to-lua/routing.lua] is version 0 Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: app_lua [app_lua_api.c:673]: app_lua_run_ex(): executing Lua function: [[ksr_onsend_route]] Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: app_lua [app_lua_api.c:675]: app_lua_run_ex(): lua top index is: 0 Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <core> [core/tcp_main.c:1993]: tcp_send(): no open tcp connection found, opening new one Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <core> [core/ip_addr.c:577]: print_ip(): tcpconn_new: new tcp connection: 14.186.47.222 Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <core> [core/tcp_main.c:1175]: tcpconn_new(): on port 60791, type 2, socket -1 Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <core> [core/tcp_main.c:1494]: tcpconn_add(): hashes: 1566:2785:0, 4 Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: <core> [core/tcp_main.c:2886]: tcpconn_1st_send(): pending write on new connection 0x14a595095d40 sock 16 (-1/539 bytes written) (err: 11 - Resource temporar ily unavailable) Aug 7 10:35:53 testnode1 /usr/local/sbin/kamailio[4806]: DEBUG: <core> [core/tcp_main.c:3792]: handle_ser_child(): read response= 14a595095d40, 5, fd 55 from 12 (4784) Aug 7 10:35:53 testnode1 /usr/local/sbin/kamailio[4806]: DEBUG: <core> [core/io_wait.h:375]: io_watch_add(): DBG: io_watch_add(0x55f0338266a0, 55, 2, 0x14a595095d40), fd_no=41 Aug 7 10:35:53 testnode1 testnode[4784]: DEBUG: app_lua [app_lua_api.c:1003]: sr_kemi_lua_exec_func_ex(): param[0] for: xdbg is str: ROUTE RELAY END:-------------------------------------------------------- ---
```
#### SIP Traffic

``` (paste your sip traffic here) ```
### Possible Solutions
<!-- If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix. -->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` kamailio -v version: kamailio 5.5.1 (x86_64/linux) 7abebb flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, 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: 7abebb compiled on 07:46:14 Jun 27 2021 with gcc 8.3.0 ```
* **Operating System**:
<!-- Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...; Kernel details (output of `uname -a`) --> Debian 10.10 ``` root@testnode1:~# uname -a Linux testnode1 4.19.0-12-cloud-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux ```
I got the same issue, seem like it's the nat map. fixed by using `handle_ruri_alias` in relay block
Closed #2814.