Hello everyone,
I'm running into a problem with SIP traffic coming in over WSS to Kamailio. As far as I know, Kamailio can't forward traffic to Asterisk over TLS, so I'm currently using UDP to send traffic from Kamailio to Asterisk via the dispatcher module. The main SIP methods involved are REGISTER and MESSAGE. Kamailio successfully receives and forwards both methods to Asterisk, though I’m not entirely sure how the message routing is working behind the scenes — but somehow, it works. The problem arises when Asterisk sends a response to a MESSAGE. In my Asterisk logs, I can see that the response is being generated, but it seems to get lost or mishandled when Kamailio tries to process or forward it.
To clarify the setup: ->Kamailio is listening on 10.5.0.8:5001 (WSS) ->It forwards traffic to Asterisk at 10.5.0.2:5060 (UDP) ->The issue specifically happens with MESSAGE replies, not REGISTER I suspect this might have something to do with mismatched transport protocols (WSS vs. UDP) or incorrect handling of routing headers in Kamailio. Any insights on how to debug or fix this properly would be greatly appreciated!
Thanks in advance.
My Code: https://docs.google.com/document/d/e/2PACX-1vSpRQmgZv1CTJW4IJ86a3SoSgPqmThMS...
Logs: <--- Transmitting SIP request (560 bytes) to UDP:10.5.0.8:5001 ---> MESSAGE sip:User1@10.5.0.8:5001;transport=ws;x-ast SIP/2.0 Via: SIP/2.0/UDP 10.5.0.2:5060;rport;branch=z9hG4bKPj8d3db1ed-d98e-4c87-ad71-ef43f47b1801 From: "Max" sip:1@172.31.217.74;tag=ae0b9d4d-89b9-489a-b5ef-3fb04fe6dd97 To: "ChatApp Max" sip:User1@10.5.0.8;x-ast Contact: sip:User1@10.5.0.2:5060 Call-ID: 0ea7b15e-f176-452a-813d-684b01923c87 CSeq: 24741 MESSAGE Max-Forwards: 70 User-Agent: Asterisk PBX 18.24.3 Content-Type: text/plain Content-Length: 74 Compreendo, por favor, avança com a tua pergunta. Estou aqui para ajudar. <--- Received SIP response (480 bytes) from UDP:10.5.0.8:5001 ---> SIP/2.0 500 I'm terribly sorry, server error occurred (1/SL) Via: SIP/2.0/UDP 10.5.0.2:5060;rport=5060;branch=z9hG4bKPj8d3db1ed-d98e-4c87-ad71-ef43f47b1801;received=10.5.0.2 From: "Max" sip:1@172.31.217.74;tag=ae0b9d4d-89b9-489a-b5ef-3fb04fe6dd97 To: "ChatApp Max" sip:User1@10.5.0.8;x-ast;tag=19162a7003f0e5d10acb0ff84f0e52ca.d3fdd014 Call-ID: 0ea7b15e-f176-452a-813d-684b01923c87 CSeq: 24741 MESSAGE Server: kamailio (5.7.6 (x86_64/linux)) Content-Length: 0 <--- Received SIP response (463 bytes) from UDP:10.5.0.8:5001 ---> SIP/2.0 500 Message processing error (2/TM) Via: SIP/2.0/UDP 10.5.0.2:5060;rport=5060;branch=z9hG4bKPj8d3db1ed-d98e-4c87-ad71-ef43f47b1801;received=10.5.0.2 From: "Max" sip:1@172.31.217.74;tag=ae0b9d4d-89b9-489a-b5ef-3fb04fe6dd97 To: "ChatApp Max" sip:User1@10.5.0.8;x-ast;tag=0e4dcc88f47817a0f29d34cc60c5db67-d3fdd014 Call-ID: 0ea7b15e-f176-452a-813d-684b01923c87 CSeq: 24741 MESSAGE Server: kamailio (5.7.6 (x86_64/linux)) Content-Length: 0
Also this are the logs kamailio is receiving: 2025/07/11 08:09:14.672978 10.5.0.2:5060 -> 10.5.0.8:5001 MESSAGE sip:10.5.0.8:5001 SIP/2.0 Via: SIP/2.0/UDP 10.5.0.2:5060;rport;branch=z9hG4bKPjf554036a-2e23-459d-b358-021391340b23 From: "Max" sip:1@172.31.217.74;tag=b516a7ed-511f-40a0-8e2e-4a1cd12380b5 To: "ChatApp Max" sip:User1@10.5.0.8;x-ast Contact: sip:User1@10.5.0.2:5060 Call-ID: 3fc3818d-af69-4c32-8977-0b7dcc0c6182 CSeq: 17652 MESSAGE Route: sip:User1@10.5.0.8:5001;transport=ws;x-ast Max-Forwards: 70 User-Agent: Asterisk PBX 18.24.3 Content-Type: text/plain Content-Length: 157
Entendido! Estou aqui para ajudar a responder oos suas perguntas de forma clara e concisa. Se houver algo mais que possa fazer por si, por favor, informe-me. 2025/07/11 08:09:14.674015 10.5.0.8:5001 -> 10.5.0.8:5001 MESSAGE sip:10.5.0.8:5001 SIP/2.0 Via: SIP/2.0/UDP 10.5.0.8:5001;branch=z9hG4bK4c.b001584ce7182eb80e392de5bd185b7b.0 Via: SIP/2.0/UDP 10.5.0.2:5060;received=10.5.0.2;rport=5060;branch=z9hG4bKPjf554036a-2e23-459d-b358-021391340b23 From: "Max" sip:1@172.31.217.74;tag=b516a7ed-511f-40a0-8e2e-4a1cd12380b5 To: "ChatApp Max" sip:User1@10.5.0.8;x-ast Contact: sip:User1@10.5.0.2:5060 Call-ID: 3fc3818d-af69-4c32-8977-0b7dcc0c6182 CSeq: 17652 MESSAGE Max-Forwards: 69 User-Agent: Asterisk PBX 18.24.3 Content-Type: text/plain Content-Length: 157 2025/07/11 08:09:14.674421 10.5.0.8:5001 -> 10.5.0.2:5060 MESSAGE sip:10.5.0.8:5001 SIP/2.0 Via: SIP/2.0/UDP 10.5.0.8:5001;branch=z9hG4bK4c.8c9177b1ae89526dcf875c794596f4b0.0 Via: SIP/2.0/UDP 10.5.0.8:5001;branch=z9hG4bK4c.b001584ce7182eb80e392de5bd185b7b.0 Via: SIP/2.0/UDP 10.5.0.2:5060;received=10.5.0.2;rport=5060;branch=z9hG4bKPjf554036a-2e23-459d-b358-021391340b23 From: "Max" sip:1@172.31.217.74;tag=b516a7ed-511f-40a0-8e2e-4a1cd12380b5 To: "ChatApp Max" sip:User1@10.5.0.8;x-ast Contact: sip:User1@10.5.0.2:5060 Call-ID: 3fc3818d-af69-4c32-8977-0b7dcc0c6182 CSeq: 17652 MESSAGE Max-Forwards: 68 User-Agent: Asterisk PBX 18.24.3 Content-Type: text/plain Content-Length: 157
Entendido! Estou aqui para ajudar a responder oos suas perguntas de forma clara e concisa. Se houver algo mais que possa fazer por si, por favor, informe-me. 2025/07/11 08:09:14.675038 10.5.0.2:5060 -> 10.5.0.8:5001 SIP/2.0 404 Not Found Via: SIP/2.0/UDP 10.5.0.8:5001;rport=5001;received=10.5.0.8;branch=z9hG4bK4c.8c9177b1ae89526dcf875c794596f4b0.0 Via: SIP/2.0/UDP 10.5.0.8:5001;branch=z9hG4bK4c.b001584ce7182eb80e392de5bd185b7b.0 Via: SIP/2.0/UDP 10.5.0.2:5060;rport=5060;received=10.5.0.2;branch=z9hG4bKPjf554036a-2e23-459d-b358-021391340b23 Call-ID: 3fc3818d-af69-4c32-8977-0b7dcc0c6182 From: "Max" sip:1@172.31.217.74;tag=b516a7ed-511f-40a0-8e2e-4a1cd12380b5 To: "ChatApp Max" sip:User1@10.5.0.8;x-ast;tag=z9hG4bK4c.8c9177b1ae89526dcf875c794596f4b0.0 CSeq: 17652 MESSAGE Server: Asterisk PBX 18.24.3 Content-Length: 0
Maybe this will give you some ideas:
https://github.com/silentindark/kamailio-private-public_wss/blob/master/kama...
It’s what I used a few years back, should still be valid.
Regards,
David Villasmil email: david.villasmil.work@gmail.com
On Fri, Jul 11, 2025 at 10:29 AM Fernando Lopes via sr-users < sr-users@lists.kamailio.org> wrote:
Hello everyone,
I'm running into a problem with SIP traffic coming in over WSS to Kamailio. As far as I know, Kamailio can't forward traffic to Asterisk over TLS, so I'm currently using UDP to send traffic from Kamailio to Asterisk via the dispatcher module. The main SIP methods involved are REGISTER and MESSAGE. Kamailio successfully receives and forwards both methods to Asterisk, though I’m not entirely sure how the message routing is working behind the scenes — but somehow, it works. The problem arises when Asterisk sends a response to a MESSAGE. In my Asterisk logs, I can see that the response is being generated, but it seems to get lost or mishandled when Kamailio tries to process or forward it.
To clarify the setup: ->Kamailio is listening on 10.5.0.8:5001 (WSS) ->It forwards traffic to Asterisk at 10.5.0.2:5060 (UDP) ->The issue specifically happens with MESSAGE replies, not REGISTER I suspect this might have something to do with mismatched transport protocols (WSS vs. UDP) or incorrect handling of routing headers in Kamailio. Any insights on how to debug or fix this properly would be greatly appreciated!
Thanks in advance.
My Code:
https://docs.google.com/document/d/e/2PACX-1vSpRQmgZv1CTJW4IJ86a3SoSgPqmThMS...
Logs: <--- Transmitting SIP request (560 bytes) to UDP:10.5.0.8:5001 ---> MESSAGE sip:User1@10.5.0.8:5001;transport=ws;x-ast SIP/2.0 Via: SIP/2.0/UDP 10.5.0.2:5060 ;rport;branch=z9hG4bKPj8d3db1ed-d98e-4c87-ad71-ef43f47b1801 From: "Max" sip:1@172.31.217.74;tag=ae0b9d4d-89b9-489a-b5ef-3fb04fe6dd97 To: "ChatApp Max" sip:User1@10.5.0.8;x-ast Contact: sip:User1@10.5.0.2:5060 Call-ID: 0ea7b15e-f176-452a-813d-684b01923c87 CSeq: 24741 MESSAGE Max-Forwards: 70 User-Agent: Asterisk PBX 18.24.3 Content-Type: text/plain Content-Length: 74 Compreendo, por favor, avança com a tua pergunta. Estou aqui para ajudar. <--- Received SIP response (480 bytes) from UDP:10.5.0.8:5001 ---> SIP/2.0 500 I'm terribly sorry, server error occurred (1/SL) Via: SIP/2.0/UDP 10.5.0.2:5060 ;rport=5060;branch=z9hG4bKPj8d3db1ed-d98e-4c87-ad71-ef43f47b1801;received=10.5.0.2 From: "Max" sip:1@172.31.217.74;tag=ae0b9d4d-89b9-489a-b5ef-3fb04fe6dd97 To: "ChatApp Max" sip:User1@10.5.0.8 ;x-ast;tag=19162a7003f0e5d10acb0ff84f0e52ca.d3fdd014 Call-ID: 0ea7b15e-f176-452a-813d-684b01923c87 CSeq: 24741 MESSAGE Server: kamailio (5.7.6 (x86_64/linux)) Content-Length: 0 <--- Received SIP response (463 bytes) from UDP:10.5.0.8:5001 ---> SIP/2.0 500 Message processing error (2/TM) Via: SIP/2.0/UDP 10.5.0.2:5060 ;rport=5060;branch=z9hG4bKPj8d3db1ed-d98e-4c87-ad71-ef43f47b1801;received=10.5.0.2 From: "Max" sip:1@172.31.217.74;tag=ae0b9d4d-89b9-489a-b5ef-3fb04fe6dd97 To: "ChatApp Max" sip:User1@10.5.0.8 ;x-ast;tag=0e4dcc88f47817a0f29d34cc60c5db67-d3fdd014 Call-ID: 0ea7b15e-f176-452a-813d-684b01923c87 CSeq: 24741 MESSAGE Server: kamailio (5.7.6 (x86_64/linux)) Content-Length: 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,
On 11.07.25 09:56, Fernando Lopes via sr-users wrote:
Hello everyone,
I'm running into a problem with SIP traffic coming in over WSS to Kamailio. As far as I know, Kamailio can't forward traffic to Asterisk over TLS,
do you know that Kamailio can't forward traffic over TLS because you read somewhere that Kamailio is not capable of that? If so, that's wrong, Kamailio can forward SIP traffic over TLS just fine, being used a lot in this manner to interconnect between providers or different instances over public internet.
Cheers, Daniel
Hello Daniel, Apologies, maybe I misread or just confused, but just to confirm: Can Kamailio forward SIP traffic received over the internet to Asterisk using TLS via the dispatcher module, instead of UDP or TCP? Currently, I have this entry: 1 sip:{{ AST_IP }}:5060 0 0 weight=10 maxload=1000
Should I change it to something like this to use TLS? 1 sip:{{ AST_IP }}:5061;transport=tls 0 0 weight=10 maxload=1000
Thanks!
On Jul 11, 2025, at 11:44 AM, Fernando Lopes via sr-users sr-users@lists.kamailio.org wrote:
Hello Daniel, Apologies, maybe I misread or just confused, but just to confirm: Can Kamailio forward SIP traffic received over the internet to Asterisk using TLS via the dispatcher module, instead of UDP or TCP? Currently, I have this entry: 1 sip:{{ AST_IP }}:5060 0 0 weight=10 maxload=1000
Should I change it to something like this to use TLS? 1 sip:{{ AST_IP }}:5061;transport=tls 0 0 weight=10 maxload=1000
Precisely, you got it.
-- Alex
-- Alex Balashov Principal Consultant Evariste Systems LLC Web: https://evaristesys.com, https://www.csrpswitch.com Tel: +1-706-510-6800
Thank you. Just a quick question—does Kamailio automatically trust Asterisk's certificate when communicating over the dispatcher, or do I need to configure something manually?