Asterisk can't connect to pjsip

Hello, I am new to asterisk and having some trouble connecting to the pjsip. I am using MircoSIP to try and connect to the pjsip on my asterisk server. The connection keeps timing out and will not go through. I am trying to connect on the same network as the one I have the asterisk server on, the server is on a virutal machine and I am trying to connect from the host machine, so I’m not sure if NAT would be an issue here.

My pjsip.conf file looks like the following:

[simpletrans]
type=transport
protocol=udp
bind=0.0.0.0

[6001]
type = endpoint
context = internal
disallow = all
allow = ulaw
aors = 6001
auth = auth6001

[6001]
type = aor
contact = sip:6001@(ip address of the virtual machine that has asterisk running):5060
max_contacts = 1

[auth6001]
type=auth
auth_type=userpass
password=1234
username=6001

[6002]
type = endpoint
context = internal
disallow = all
allow = ulaw
aors = 6002
auth = auth6002

[6002]
type = aor
contact = sip:6002@(ip address of the virtual machine that has asterisk running):5060

[auth6002]
type=auth
auth_type=userpass
password=1234
username=6001

When I run ‘pjsip show endpoints’ on the Asterisk command line it gives me the following.

Endpoint: 6001 Not in use 0 of inf
InAuth: auth6001/6001
Aor: 6001 1
Contact: 6001/sip:6001@(ip address of the virtual machine that has asterisk running):5060 7b334d6fcf NonQual nan

Endpoint: 6002 Not in use 0 of inf
InAuth: auth6002/6001
Aor: 6002 0
Contact: 6002/sip:6002@(ip address of the virtual machine that has asterisk running):5060 a38543284f NonQual nan

Objects found: 2

Can someone please help? I am not sure why it doesn’t work when I try and connect to it using MicroSIP.

I believe the address should be that of the machine on which MicroSIP is running, i.e. it is the address that MicroSIP would provide if it were registering with Asterisk.

If the MicroSIP machine have a dynamic IP this will be an issue, better don’t add contact parameter when you are expecting the SIP User Agent (likely a phone) to register against the AOR. In this case, the contact objects will be created automatically

I did try putting the IP address of the host machine, which is running MicroSIP. That also didn’t help in connection, it still timed out.

Have you configured the Linux firewall to accept port 5060 over UDP?

Are the request packets arriving on the machine, as seen by tcpdump?

Are the packets arriving at Asterisk as seen using PJSIP debugging on Asterisk?

If so, what appears in the Asterisk log regarding their fate?

Hi, thanks for the reply. When I remove contact, it still doesn’t connect and it also shows the status of the endpoints as unavailable when I ask on Asterisk. When I add a contact it shows not in use rather than unavailable. It also still won’t connect?

I disabled iptables, my machine doesn’t have fail2ban, is there something else I need to do for firewall?

How do I know if the packets are arriving at Asterisk? When I try connecting, and have the CLI open, even with 25 verbosity, it doesn’t show anything. Is there another way to check?

sngrep will show any packers going to the system even before asterisk

Use tcpdump, with a filter for port 5060.

Use wirekshark (Windows) or tcpdump on the softphone machine to see if packets are being sent.

If you have confirmed they are arriving at the Asterisk machine, and are not being rejected at the OS level, look into Collecting Debug Information - Asterisk Project - Asterisk Project Wiki

Hey,

Thanks for your replies. So I was working form home yesterday and for some reason when I followed the collecting debug information, it was just able to connect to my pjsip. Now that I’m trying on my work network again, the pjsip is failing to connect. Do you have any idea why that might be?

I will add a +1 for the sngrep tool on the command like of the asterisk box. It is a great tool for visualizing and inspecting sip messages.

Launch it via >sngrep and then test out your endpoint, and come back to view what is displayed in sngrep

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.