Maybe this will give you some ideas:

https://github.com/silentindark/kamailio-private-public_wss/blob/master/kamailio.cfg

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-1vSpRQmgZv1CTJW4IJ86a3SoSgPqmThMSmmpWWjXfwC0pZCp7mos-4QmNnW9uDC3dR9B66UL3Re4AX9z/pub

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!