KeanePW created an issue (kamailio/kamailio#4532)
### Description
When using htable DMQ replication (`modparam("htable", "enable_dmq", 1)` with
`dmqreplicate=1` on htable definitions), htable sync messages are malformed on
the wire. The `Max-Forwards` and `Content-Type` headers are incorrectly placed
**inside the SIP message body** instead of in the header section.
The receiving node's htable DMQ handler (`ht_dmq_handle_msg()`) then attempts
to parse `Max-Forwards: 1\r\nContent-Type:
application/json\r\n\r\n{"action":...}` as JSON, which fails with "invalid json
doc".
**Expected behavior:** htable DMQ replication should work - nodes should sync
htable entries via DMQ.
**Actual behavior:** All htable DMQ messages receive 400 Bad Request responses.
The `notification_peer` messages work correctly (200 OK), but `htable` messages
fail.
### Troubleshooting
#### Reproduction
1. Configure 2+ Kamailio 6.0.1 nodes with DMQ enabled
2. Enable htable DMQ replication:
```kamailio
loadmodule "dmq.so"
modparam("dmq", "server_address", "sip:NODE_IP:5065")
modparam("dmq", "notification_address", "sip:OTHER_NODE:5065")
modparam("htable", "enable_dmq", 1)
modparam("htable", "dmq_init_sync", 1)
modparam("htable", "htable", "test=>size=8;autoexpire=300;dmqreplicate=1")
```
3. Add an entry to the htable: `kamcmd htable.seti test mykey 123`
4. Observe DMQ traffic with sngrep on port 5065
5. Check logs for "invalid json doc" errors
#### Log Messages
```
Dec 19 12:01:45 us-dc4-cvp-1 /usr/sbin/kamailio[1030]: ERROR: htable
[ht_dmq.c:305]: ht_dmq_handle_msg(): invalid json doc [[Max-Forwards: 1
Dec 19 12:01:45 us-dc4-cvp-1 /usr/sbin/kamailio[1030]: ERROR: htable
[ht_dmq.c:305]: ht_dmq_handle_msg(): invalid json doc [[Max-Forwards: 1
Dec 19 12:01:51 us-dc4-cvp-1 /usr/sbin/kamailio[1030]: ERROR: dmq
[dmqnode.c:202]: build_dmq_node(): error parsing uri
Dec 19 12:01:51 us-dc4-cvp-1 /usr/sbin/kamailio[1030]: ERROR: dmq
[notification_peer.c:413]: extract_node_list(): error building dmq node
```
The error message shows the body starts with `[Max-Forwards: 1` - this is a SIP
header that should be in the header section, not the body.
#### SIP Traffic
**Malformed htable KDMQ message (captured via sngrep):**
```
KDMQ sip:[email protected]:5065 SIP/2.0
Via: SIP/2.0/UDP
38.109.158.168:5065;branch=z9hG4bK8597.375df481000000000000000000000000.0
To: <sip:[email protected]:5065>
From:
<sip:[email protected]:5065>;tag=5139ac70b43c1bbf07cee0c4f0e19f64-9fd496da
CSeq: 10 KDMQ
Call-ID: [email protected]
Content-Length: 79
User-Agent: CVP/1.0 (us-sv2-cvp-1)
Max-Forwards: 1
Content-Type: application/json
{"action":2,"htname":"dno","cname":"6157524332","type":2,"strval":"0","mode":1}
```
**Note:** The `Content-Length: 79` only accounts for the JSON payload (79
bytes), but `Max-Forwards: 1\r\nContent-Type: application/json\r\n\r\n` is
prepended to the body. This causes the htable parser to receive headers as part
of the body content.
**For comparison, `notification_peer` messages work correctly** and receive 200
OK responses.
### Possible Solutions
The issue appears to be in how htable DMQ messages construct the SIP request.
The headers string is built but may be getting appended incorrectly when passed
to the DMQ send function.
Possible locations to investigate:
- `src/modules/htable/ht_dmq.c` - `ht_dmq_replicate_action()` function
- `src/modules/dmq/dmq_funcs.c` - `bcast_dmq_message1()` or related functions
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 6.0.1 (x86_64/linux)
```
(All 4 nodes in cluster running identical version)
* **Operating System**:
```
Debian 13.2 (Trixie)
Linux us-dc4-cvp-1 6.12.57+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.57-1
(2025-11-05) x86_64
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4532
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/[email protected]>_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the
sender!