PJSIP And Kamailio Without Registration
Hi,
I want to have Kamailio in front of one or more Asterisk boxes.
I don’t think it is necessary for Kamailio and Asterisk to register with one another. I’d like for PJSIP to recognise Kamailio by its IP address.
I have two boxes, both have public IP addresses, they also have private IP
addresses and can communicate with each other.
I have a Snom phone accessing Kamailio via its public IP address.
Kamailio sends traffic to asterisk on the private IPs.
Doing an ngrep on 5061 (where I have tcp and udp set up for pjsip) I can see Kamailio sending traffic to the Asterisk box, however in the console I
see no activity. I have verbose and debug set to 10, and pjsip set logger on.
I’m a bit stumped, I’ve tried everything I could think of, even configuring everything to work on the public IP, but no luck.
Here’s my PJSIP conf:
[kamailio]
type=endpoint transport=transport-udp context=from_kamailio disallow=all allow=alaw allow=g722
allow=ulaw aors=kamailio direct_media=no rtp_symmetric=no force_rport=no rewrite_contact=no
[kamailio]
type=identify endpoint=kamailio match=xxx.xxx.xxx.xxx (removed kamailios private IP)
[kamailio-mars]
type=aor contact=sip:xxx.xxx.xxx.xxx:5060 (removed kamailios private IP).
My end goal is for all my phones to register to Kamailio. Kamailio should pass calls (even for local phones) to Asterisk.
Thanks in advance for your help.
C
8 thoughts on - PJSIP And Kamailio Without Registration
Chirag Desai wrote:
Have you configured any transports? PJSIP does not create any by default, you have to explicitly configure them. Without them no traffic can come in or go out. You can also remove the explicit transport from the endpoint.
Joshua Colp wrote:
Yes I have two transports
[transport-udp]
type=transport protocol=udp ;udp,tcp,tls,ws,wss bind=0.0.0.0:5061
[transport-tcp-kamailio]
type=transport protocol=tcp bind=0.0.0.0:5061
I’ve tried explicitly setting the IP in bind and leaving it as above. Nothing seems to come into asterisk. Although, as mentioned I can see the SIP messages when I ngrep 5061.
Kind Regards,
C
Chirag Desai wrote:
I got it working, I can see the sip traffic in the CLI now.
I was trying to match on the IP of kamailio, when really I should have been
matching on the domain name in the sip message (I believe in the TO field).
I can place a call now, but keep getting unauthorized. Not sure why
since the endpoint doesn’t have any auth credentials.
Any ideas?
OK, it stopped working.
It turns out the transport and endpoints in PJSIP are ok. I can send an invite from my unregistered snom phone and I can see some activity in the CLI.
However, when I dial from my snom to Kamailio and have it pass the message to asterisk, PJSIP seems to ignore the sip messages even though they are there.
Is there something wrong in the invite that I’m missing?
U 2015/03/10 22:47:43.539208 [kamailio public ip]:5060 -> [asterisk public ip]:5061. Record-Route: . Via: SIP/2.0/UDP 1;tag=tu0if9akzq. To: . Call-ID: 8d74ff54e076-hajfjxwp1crj. CSeq: 2 INVITE. Max-Forwards: 16. Contact: ;reg-id=1. X-Serialnumber: [snom_mac_address]. P-Key-Flags: resolution=”31×13″, keys=”4″. User-Agent: snom760/8.7.3.25. Accept: application/sdp. Allow: INVITE, ACK, CANCEL, BYE, REFER, OPTIONS, NOTIFY, SUBSCRIBE, PRACK, MESSAGE, INFO, UPDATE. Allow-Events: talk, hold, refer, call-info. Supported: timer, 100rel, replaces, from-change. Session-Expires: 3600;refresher=uas. Min-SE: 90. Content-Type: application/sdp. Content-Length: 598.
INVITE sip:1000@somedomain.com;user=phone SIP/2.0. Record-Route:
[kamailio public ip];branch=z9hG4bKc10a.a307d27e5d7581c259704fcd865a69e2.0;i=1. Via: SIP/2.0/TCP
[snomprivateip]:47153;received=[snompublicip];branch=z9hG4bK-cc9ldmdhvvdi;rportG473. From:
. v=0. o=root 1667335791 1667335791 IN IP4 [snom_private_ip]. s
If the INVITE request is not shown in the CLI with ‘pjsip set logger on’, then Asterisk is not actually receiving the request.
Does a pcap show the message being sent to the correct IP/port? If you change the transports to bind to port 5060, does that change anything?
The sip message I included in my last message is what I see when I ngrep on
5061, but asterisk doesn’t see it. When I tell Kamailio to send the message to 5060 chan_sip shows the invite in the CLI.
My setup has chan_sip running on 5060 and pjsip (tcp and udp on 5061).
I’ll get PJSIP running on 5060 and see if that makes any difference.
— C
From: Matthew Jordan
on 5061, but >asterisk doesn’t see it. When I tell Kamailio to send the message to 5060 chan_sip shows >the invite in the CLI.
UPDATE: I got PJSIP on 5060 and everything is working fine as expected and I can see the calls from Kamalio. Is this a bug with asterisk not recognising the traffic on 5061 even though the SIP messages are being received by the server on that port and I can see it?
I suspect not. We run the PJSIP stack on multiple ports quite often. I
would guess that there’s something else going on here.