Asterisk compile error solution “‘pjsip_tcp_transport_cfg’ has no member named ‘sockopt_params’”

Once I compiled Asterisk version 13.13.1 and when running make I noticed the following error:

‘pjsip_tcp_transport_cfg’ has no member named ‘sockopt_params’

pjproject-2.2.1 has already been compiled.

Solved the problem by compiling a newer version of pjproject-2.4.5

cd /usr/src
wget http://www.pjsip.org/release/2.4.5/pjproject-2.4.5.tar.bz2
tar -xjvf pjproject-2.4.5.tar.bz2
cd pjproject-2.4.5
CFLAGS='-DPJ_HAS_IPV6=1' ./configure --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr
make dep
make
make install

After that, the error disappeared.

Adding SIP clients to Asterisk

SIP clients in Asterisk are specified in the sip.conf file, so open it for example in the nano text editor (Ctrl+X to exit the editor, y or n to save or discard changes):

sudo nano /etc/asterisk/sip.conf

First we specify the following parameter, forbidding anonymous calls:

allowguest=no

Now at the very end of the file, add the client:

[6000]
type=friend
secret=PASSWORD
nat=no
host=dynamic
dtmfmode=rfc2833
disallow=all
allow=ulaw
context=sip-dialout
callerid=6000
deny=0.0.0.0/0
permit=192.168.0.10/32

Briefly describe the parameters that I indicated:
type – type of client, can be user (authentication by password), peer (identification by host address), fried (either by password or by host).
secret – user password.
nat=no – indicates that the client may be behind NAT, see my article about this – Solution to the Asterisk problem – no sound when calling via NAT.
host=dynamic – there is no client binding to the host address.
dtmfmode=rfc2833 – method of transmitting dtmf dialing tones.
disallow=all – ban all codecs.
allow=ulaw – Let’s solve only the ulaw codec.
context=sip-dialout — the name of the dialplan (it is described in extensions.conf)
callerid=6000 – customer’s internal phone number.
deny=0.0.0.0/0 – we forbid connection from all IP addresses.
permit=192.168.0.10/32 – we only allow connection from the specified IP address.

After adding the client, we will connect to Asterisk and update the sip configuration:

sudo asterisk -r
sip reload

To see the list of clients you can use the command:

sip show users

To exit the Asterisk console, type:

quit

Now it is already possible to connect the added client to the Asterisk server using for example the X-Lite, Zoiper or VoIP phone program, but there is nowhere to call, so we will add the second client to sip.conf for the test:

[6001]
type=friend
secret=PASSWORD
nat=no
host=dynamic 
dtmfmode=rfc2833
disallow=all
allow=ulaw
context=sip-dialout
callerid=6001
deny=0.0.0.0/0
permit=192.168.0.10/32

Open the extensions.conf file in the editor:

sudo nano /etc/asterisk/extensions.conf

And we will indicate the following lines at the end of it, so that users can call each other:

[sip-dialout]
exten => 6000,1,Dial(SIP/6000)
exten => 6001,1,Dial(SIP/6001)

Restart Asterisk to apply the changes:

sudo service asterisk restart

Done, we added two users and they can call each other.

See also:
Adding a SIP client to FreePBX

Adding a SIP client to FreePBX

To add a SIP client to FreePBX, open the menu “Applications” – “Extensions“, choose for example “Generic CHAN SIP Device” and we indicate the main parameters:

User Extension: 6000 (SIP number)
Display Name: Operator (any name to display)
Secret: PASSWORD
and click “Submit“.

Done, SIP is added, it can already be registered at the specified number and password.

How to add SIP in the configuration file I described in this article – Adding SIP clients to Asterisk

Solution to the Asterisk problem – no sound when calling via NAT

I noticed recently that there is no sound when calling from IP-phone to another IP-phone which were both behind the same NAT (router).

Therefore, in the sip.conf configuration for these accounts, you need to specify that they are behind NAT, specifying the parameter:

nat=force_rport,comedia

I want to note that the value of “yes” for nat is already obsolete since version Asterisk 11, so it will be correct as mentioned above.

And also point at no to the directmedia parameter, so that Asterisk does not send packets to the same port from which it was received (which in my case happened, both phones connected to Asterisk from the same IP, with the same ports):

directmedia=no

Done.