Hello everyone,
I’m having some problems routing a MESSAGE from Asterisk to a WebRTC client. Regular calls work fine, but MESSAGE handling is failing. Kamailio: 10.5.0.8 Asterisk: 10.5.0.2
I suspect the problem could be one of two things: ->The CSeq values don’t match (CSeq: 2 MESSAGE vs CSeq: 49306 MESSAGE). ->The To and From headers might be preventing Kamailio from knowing where to send the reply. Has anyone seen this behavior before? Any suggestions on how to correctly route MESSAGEs through Kamailio to WebRTC clients?
Here are some logs: MESSAGE sip:7@172.31.217.74 SIP/2.0 Transport: udp Record-Route: sip:172.31.217.74:5001;r2=on;lr;ftag=124pqf5crm;nat=yes Record-Route: sip:172.31.217.74:8087;transport=ws;r2=on;lr;ftag=124pqf5crm;nat=yes Via: SIP/2.0/UDP 172.31.217.74:5001;branch=z9hG4bK43b3.e83a57badbec3df404fc69a3c7f0e666.0 Via: SIP/2.0/WSS ip9sqfgevvko.invalid;rport=59806;received=172.31.208.1;branch=z9hG4bK324262 To: sip:7@172.31.217.74 From: "916c67e8-652f-49ea-b288-2bbbee8dbf21" sip:User1@172.31.217.74;tag=124pqf5crm CSeq: 2 MESSAGE Call-ID: s1djti0r9egfcvi1n4aa Max-Forwards: 69 Authorization: Digest algorithm=MD5, username="User1", realm="xxxxx", nonce="1756131542/ed3931083af68713eb56098000b661ec", uri="sip:7@172.31.217.74", response="3a474fc4f735e602a7b1940d0c9da564", opaque="10b0b5293ff53cc5", qop=auth, cnonce="0reui7po4gfn", nc=00000001 Supported: outbound User-Agent: SIP.js/0.21.1 Content-Type: text/plain Content-Length: 68
{"message":"ola","sessionId":"feff3811-f3b4-4dd7-8125-af9fe80dd523"}
Some log from asterisk: pjsip:User1/sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8:5001;x-ast;transport=udp,"MaxTalk" sip:7@172.31.217.74,"ChatApp xxxxx" sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8:5001;x-ast"
<--- Transmitting SIP request (687 bytes) to UDP:10.5.0.8:5001 ---> MESSAGE sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8:5001;transport=udp;x-ast SIP/2.0 Via: SIP/2.0/UDP 10.5.0.2:4040;rport;branch=z9hG4bKPj782df7e5-c4b7-4f74-98ff-611d39069cc5 From: "MaxTalk" sip:7@172.31.217.74;tag=645539f3-3177-436a-88f6-ac7f64735fd4 To: "ChatApp xxxxx" sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8;x-ast Contact: sip:User1@10.5.0.2:4040 Call-ID: 2af343eb-67f5-4458-ba07-37b830169ec7 CSeq: 49306 MESSAGE Max-Forwards: 70 User-Agent: Asterisk PBX 18.24.3 Content-Type: text/plain Content-Length: 138
Olá! Como posso ajudar-te hoje? Se tiveres alguma dúvida sobre a plataforma da xxxxx ou qualquer outra questão, estou aqui para ajudar. <--- Received SIP response (476 bytes) from UDP:10.5.0.8:5001 ---> SIP/2.0 483 Too Many Hops Via: SIP/2.0/UDP 10.5.0.2:4040;received=10.5.0.2;rport=4040;branch=z9hG4bKPj782df7e5-c4b7-4f74-98ff-611d39069cc5 From: "MaxTalk" sip:7@172.31.217.74;tag=645539f3-3177-436a-88f6-ac7f64735fd4 To: "ChatApp xxxxx" sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8;x-ast;tag=19162a7003f0e5d10acb0ff84f0e52ca.11182266 Call-ID: 2af343eb-67f5-4458-ba07-37b830169ec7 CSeq: 49306 MESSAGE Server: kamailio (5.7.6 (x86_64/linux)) Content-Length: 0
Thank you.
my bet goes to the Request URI, not the CSeq, reason why Kamailio is very likely looping it back to itself until Max-Forwards hits 0 ==> 483 Too Many Hops.
As far as remember, routing of MESSAGE is based on the Request-URI (R-URI), not To/From. I think the CSeq mismatch is irrelevant here because these are out-of-dialog MESSAGEs (no To tag), so each transaction has its own CSeq.
Atenciosamente / Kind Regards / Cordialement / Un saludo,
*Sérgio Charrua*
On Mon, Aug 25, 2025 at 4:05 PM Fernando Lopes via sr-users < sr-users@lists.kamailio.org> wrote:
Hello everyone,
I’m having some problems routing a MESSAGE from Asterisk to a WebRTC client. Regular calls work fine, but MESSAGE handling is failing. Kamailio: 10.5.0.8 Asterisk: 10.5.0.2
I suspect the problem could be one of two things: ->The CSeq values don’t match (CSeq: 2 MESSAGE vs CSeq: 49306 MESSAGE). ->The To and From headers might be preventing Kamailio from knowing where to send the reply. Has anyone seen this behavior before? Any suggestions on how to correctly route MESSAGEs through Kamailio to WebRTC clients?
Here are some logs: MESSAGE sip:7@172.31.217.74 SIP/2.0 Transport: udp Record-Route: sip:172.31.217.74:5001;r2=on;lr;ftag=124pqf5crm;nat=yes Record-Route: sip:172.31.217.74:8087 ;transport=ws;r2=on;lr;ftag=124pqf5crm;nat=yes Via: SIP/2.0/UDP 172.31.217.74:5001 ;branch=z9hG4bK43b3.e83a57badbec3df404fc69a3c7f0e666.0 Via: SIP/2.0/WSS ip9sqfgevvko.invalid;rport=59806;received=172.31.208.1;branch=z9hG4bK324262 To: sip:7@172.31.217.74 From: "916c67e8-652f-49ea-b288-2bbbee8dbf21" <sip:User1@172.31.217.74
;tag=124pqf5crm
CSeq: 2 MESSAGE Call-ID: s1djti0r9egfcvi1n4aa Max-Forwards: 69 Authorization: Digest algorithm=MD5, username="User1", realm="xxxxx", nonce="1756131542/ed3931083af68713eb56098000b661ec", uri=" sip:7@172.31.217.74", response="3a474fc4f735e602a7b1940d0c9da564", opaque="10b0b5293ff53cc5", qop=auth, cnonce="0reui7po4gfn", nc=00000001 Supported: outbound User-Agent: SIP.js/0.21.1 Content-Type: text/plain Content-Length: 68
{"message":"ola","sessionId":"feff3811-f3b4-4dd7-8125-af9fe80dd523"}
Some log from asterisk: pjsip:User1/sip:916c67e8-652f- 49ea-b288-2bbbee8dbf21@10.5.0.8:5001;x-ast;transport=udp,"MaxTalk" < sip:7@172.31.217.74>,"ChatApp xxxxx" sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8:5001;x-ast"
<--- Transmitting SIP request (687 bytes) to UDP:10.5.0.8:5001 ---> MESSAGE sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8:5001;transport=udp;x-ast SIP/2.0 Via: SIP/2.0/UDP 10.5.0.2:4040 ;rport;branch=z9hG4bKPj782df7e5-c4b7-4f74-98ff-611d39069cc5 From: "MaxTalk" <sip:7@172.31.217.74
;tag=645539f3-3177-436a-88f6-ac7f64735fd4
To: "ChatApp xxxxx" sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8 ;x-ast Contact: sip:User1@10.5.0.2:4040 Call-ID: 2af343eb-67f5-4458-ba07-37b830169ec7 CSeq: 49306 MESSAGE Max-Forwards: 70 User-Agent: Asterisk PBX 18.24.3 Content-Type: text/plain Content-Length: 138
Olá! Como posso ajudar-te hoje? Se tiveres alguma dúvida sobre a plataforma da xxxxx ou qualquer outra questão, estou aqui para ajudar. <--- Received SIP response (476 bytes) from UDP:10.5.0.8:5001 ---> SIP/2.0 483 Too Many Hops Via: SIP/2.0/UDP 10.5.0.2:4040 ;received=10.5.0.2;rport=4040;branch=z9hG4bKPj782df7e5-c4b7-4f74-98ff-611d39069cc5 From: "MaxTalk" <sip:7@172.31.217.74
;tag=645539f3-3177-436a-88f6-ac7f64735fd4
To: "ChatApp xxxxx" sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8 ;x-ast;tag=19162a7003f0e5d10acb0ff84f0e52ca.11182266 Call-ID: 2af343eb-67f5-4458-ba07-37b830169ec7 CSeq: 49306 MESSAGE Server: kamailio (5.7.6 (x86_64/linux)) Content-Length: 0
Thank you. __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
So, when Kamailio receives this, it thinks about the message itself rather than the client and doesn’t know where to send it. Is that correct? If so, how can I fix this issue? Would I need to check if message comes from internal ip and if so relay to the client? <--- Transmitting SIP request (687 bytes) to UDP:10.5.0.8:5001 ---> MESSAGE sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8:5001;transport=udp;x-ast SIP/2.0
Messages routed exactly the same way other requests routed. Either you provide proper Request URI from asterisk, either you do lookup into location to identify the receiver.
Your message contains kamailio ruri. So I would expect to do lookup for this message
On Mon, Aug 25, 2025, 19:40 Fernando Lopes via sr-users < sr-users@lists.kamailio.org> wrote:
So, when Kamailio receives this, it thinks about the message itself rather than the client and doesn’t know where to send it. Is that correct? If so, how can I fix this issue? Would I need to check if message comes from internal ip and if so relay to the client? <--- Transmitting SIP request (687 bytes) to UDP:10.5.0.8:5001 ---> MESSAGE sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8:5001;transport=udp;x-ast SIP/2.0 __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
not sure... I am assuming that your users are registered... however your Asterisk sends something like MESSAGE sip:916c67e8-...@10.5.0.8:5001;transport=udp but the user part (916c67e8-....) seems to be a display/name, as it looks like a UUID, not a registered AOR (like User1, User2, etc... ). I guess Kamailio can’t lookup("location") for that AOR, and then re-targets/forwards in a way that loops back to itself resulting in SIP 483 ....
just a wild guess.... but in your Asterisk dialplan you should try to get the target AOR user and set it to the MESSAGE(to) variable, prior to sending the message... on Kamailio just save the location upon register, and on relay lookup for user AOR to location, etc... and relay the message.
if you run a kamcmd ul.dump you should get an idea of the registered endpoints
again, verrrrryyyyy wild guess and assuming lots of things :)
Atenciosamente / Kind Regards / Cordialement / Un saludo,
*Sérgio Charrua*
On Mon, Aug 25, 2025 at 6:34 PM Fernando Lopes via sr-users < sr-users@lists.kamailio.org> wrote:
So, when Kamailio receives this, it thinks about the message itself rather than the client and doesn’t know where to send it. Is that correct? If so, how can I fix this issue? Would I need to check if message comes from internal ip and if so relay to the client? <--- Transmitting SIP request (687 bytes) to UDP:10.5.0.8:5001 ---> MESSAGE sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@10.5.0.8:5001;transport=udp;x-ast SIP/2.0 __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Hello Sergio, I'm trying the location method but can't seem to work. I have this code: modparam("registrar", "method_filtering", 1) modparam("registrar", "append_branches", 0) modparam("registrar", "max_contacts", 10) modparam("registrar", "max_expires", 3600) modparam("registrar", "gruu_enabled", 0)
xlog("L_WARN", "[REQUEST] R-URI User: $fu, Domain: $du\n"); # Try to lookup the user location if (!lookup("location")) { xlog("L_WARN", "[REQUEST] Location lookup failed for user: $tU\n"); t_newtran(); send_reply("404", "User Not Found"); exit; } And this inside kamcmd ul.dump { Domains: { Domain: { Domain: location Size: 1024 AoRs: { Info: { AoR: user1 HashID: 2079352211 Contacts: { Contact: { Address: sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@gpj62dasapt6.invalid Expires: 408 Q: -1 Call-ID: nl90f1bhf5lv9jt79dp4 CSeq: 4 User-Agent: n/a Received: sip:172.31.208.1:61031;transport=ws Path: [not set] State: CS_NEW Flags: 0 CFlags: 0 Socket: udp:10.5.0.8:5001 Methods: -1 Ruid: uloc-68addea4-31-1 Instance: [not set] Reg-Id: 0 Server-Id: 0 Tcpconn-Id: -1 Keepalive: 0 Last-Keepalive: 1756225263 KA-Roundtrip: 0 Last-Modified: 1756225263 } } } } Stats: { Records: 1 Max-Slots: 1 } } } } and this logs: (49) WARNING: <script>: [REQUEST] MESSAGE from Asterisk (10.5.0.2), attempting location lookup for User1 4(49) WARNING: <script>: [REQUEST] R-URI User: sip:User1@172.31.217.74, Domain: <null> 4(49) WARNING: <script>: [REQUEST] Location lookup failed for user: User1
Thank you for the help.
Your R-URI user isn't from $fu. It is at $ru.
On Tue, Aug 26, 2025, 19:10 Fernando Lopes via sr-users < sr-users@lists.kamailio.org> wrote:
Hello Sergio, I'm trying the location method but can't seem to work. I have this code: modparam("registrar", "method_filtering", 1) modparam("registrar", "append_branches", 0) modparam("registrar", "max_contacts", 10) modparam("registrar", "max_expires", 3600) modparam("registrar", "gruu_enabled", 0)
xlog("L_WARN", "[REQUEST] R-URI User: $fu, Domain: $du\n"); # Try to lookup the user location if (!lookup("location")) { xlog("L_WARN", "[REQUEST] Location lookup failed for user:$tU\n"); t_newtran(); send_reply("404", "User Not Found"); exit; } And this inside kamcmd ul.dump { Domains: { Domain: { Domain: location Size: 1024 AoRs: { Info: { AoR: user1 HashID: 2079352211 Contacts: { Contact: { Address: sip:916c67e8-652f-49ea-b288-2bbbee8dbf21@gpj62dasapt6.invalid Expires: 408 Q: -1 Call-ID: nl90f1bhf5lv9jt79dp4 CSeq: 4 User-Agent: n/a Received: sip: 172.31.208.1:61031;transport=ws Path: [not set] State: CS_NEW Flags: 0 CFlags: 0 Socket: udp: 10.5.0.8:5001 Methods: -1 Ruid: uloc-68addea4-31-1 Instance: [not set] Reg-Id: 0 Server-Id: 0 Tcpconn-Id: -1 Keepalive: 0 Last-Keepalive: 1756225263 KA-Roundtrip: 0 Last-Modified: 1756225263 } } } } Stats: { Records: 1 Max-Slots: 1 } } } } and this logs: (49) WARNING: <script>: [REQUEST] MESSAGE from Asterisk (10.5.0.2), attempting location lookup for User1 4(49) WARNING: <script>: [REQUEST] R-URI User: sip:User1@172.31.217.74, Domain: <null> 4(49) WARNING: <script>: [REQUEST] Location lookup failed for user: User1
Thank you for the help. __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Can I save the UUID and match based on it, or do I need to match based on the AoR? If there are multiple connections, won’t the table store multiple entries with the same AoR, making it difficult for Kamailio to match?