[SOLVED] SIP to PJSIP realtime convertion problem

Up until now, I have been using chan_sip, though from reading up a lot I understand that chan_pjsip is the preferred protocol, so I would like to make the switch before chan_sip is obsolete.

At the moment I am trying out everything in a local network and I have been mostly successful in the conversion except for dialing to another extension from Asterisk.

In the chan_sip configuration the following happens :
An end user (agent) registers for receiving calls only (WebRTC, MicroSIP or Ekiga).
Another end user (client) registers (WebRTC, MicroSIP or Ekiga).
The client selects to dial the agent.
Asterisks sends INVITE to agent
Asterisks receives INVITE
Asterisks receives Ringing 180
Asterisks receives OK 200
Asterisks sends ACK
Asterisks receives INFO
Asterisks sends OK
The agents hears a messages prior to receiving the call.
Both ends talk until 1 terminates the call.

In the chan_pjsip configuration the following happens :
The client selects to dial the agent.
Asterisks sends INVITE to agent
Asterisks receives INVITE
Asterisks receives Ringing 180
Asterisks receives OK 200
Asterisks sends ACK
Asterisks sends BYE

I probably have something wrong in the configuration files or the realtime database, though after a lot of searching and trying I seem to be stuck.
I did notice the following differences in the headers :

chan_sip

From: “Callsystem system test” sip:_DNIS_@10.0.0.101:0;tag=as5b5162bf
To: sips:_REM_ID_@df7jal23ls0d.invalid;rtcweb-breaker=no;transport=wss;tag=0HlXfVEkRKka2LkH0hrM
Contact: sip:_DNIS_@10.0.0.101:0;transport=WS

chan_pjsip

From: “Callsystem system test” sip:_DNIS_@call-01.mydomain.com;tag=CC3jyX6pHTQ.ioxfBZODVSB51-z1q8u1
To: sips:_REM_ID_@10.0.0.204;rtcweb-breaker=no
Contact: sips:asterisk@call-01.mydomain.com:5060;transport=TLS

Notice that sip uses the local servers ip,transport=WS and pjsip the domain name and transport=TLS

This is the pjsip.conf :

[general]
useragent=MY_ID-MYDOMAIN.COM

[UDP]
type=transport
protocol=udp
bind=0.0.0.0:5060
local_net=10.0.0.0/24
;external_media_address=10.0.0.101
;external_signaling_address=10.0.0.101
;external_media_address=10.0.0.101
;external_signaling_address=10.0.0.101
;external_signaling_port=5060

[WebRTC]
type=transport
protocol=wss
bind=0.0.0.0:8089
cert_file=/etc/asterisk/keys/asterisk.crt
priv_key_file=/etc/asterisk/keys/asterisk.key
;local_net=192.168.0.0/24
local_net=10.0.0.0/24
;external_media_address=10.0.0.101
;external_signaling_address=10.0.0.101

These are the realtime database settings :
ps_aors

                             id: _REM_ID_
                        contact: NULL
             default_expiration: NULL
                      mailboxes: NULL
                   max_contacts: 1
             minimum_expiration: NULL
                remove_existing: NULL
              qualify_frequency: NULL
           authenticate_qualify: NULL
             maximum_expiration: NULL
                 outbound_proxy: NULL
                   support_path: NULL
                qualify_timeout: NULL
            voicemail_extension: NULL

ps_auths

                             id: _REM_ID_
                      auth_type: userpass
                 nonce_lifetime: NULL
                       md5_cred: NULL
                       password: some_password
                          realm: NULL
                       username: _REM_ID_
                       lastused: 0
                       ipaddr_c: 0

ps_endpoints

                     id: _REM_ID_
                     transport: WebRTC
                          aors: _REM_ID_
                          auth: _REM_ID_
                       context: from-internal
                      disallow: all
                         allow: alaw
                  direct_media: no
         connected_line_method: NULL
           direct_media_method: NULL
 direct_media_glare_mitigation: NULL
   disable_direct_media_on_nat: NULL
                     dtmf_mode: NULL
        external_media_address: NULL
                   force_rport: yes
                   ice_support: yes
                   identify_by: NULL
                     mailboxes: NULL
                   moh_suggest: NULL
                 outbound_auth: NULL
                outbound_proxy: NULL
               rewrite_contact: yes
                      rtp_ipv6: NULL
                 rtp_symmetric: yes
                send_diversion: NULL
                      send_pai: NULL
                     send_rpid: NULL
                 timers_min_se: NULL
                        timers: NULL
           timers_sess_expires: NULL
                      callerid: NULL
              callerid_privacy: NULL
                  callerid_tag: NULL
                        100rel: NULL
                 aggregate_mwi: NULL
              trust_id_inbound: NULL
             trust_id_outbound: NULL
                     use_ptime: NULL
                      use_avpf: yes
              media_encryption: dtls
               inband_progress: NULL
                    call_group: NULL
                  pickup_group: NULL
              named_call_group: NULL
            named_pickup_group: NULL
          device_state_busy_at: NULL
                    fax_detect: NULL
                     t38_udptl: NULL
                  t38_udptl_ec: NULL
         t38_udptl_maxdatagram: NULL
                 t38_udptl_nat: NULL
                t38_udptl_ipv6: NULL
                     tone_zone: NULL
                      language: NULL
           one_touch_recording: NULL
             record_on_feature: NULL
            record_off_feature: NULL
                    rtp_engine: NULL
                allow_transfer: NULL
               allow_subscribe: NULL
                     sdp_owner: NULL
                   sdp_session: NULL
                     tos_audio: NULL
                     tos_video: NULL
                sub_min_expiry: NULL
                   from_domain: NULL
                     from_user: NULL
                 mwi_from_user: NULL
                   dtls_verify: fingerprint
                    dtls_rekey: 0
                dtls_cert_file: /etc/asterisk/keys/asterisk.pem
              dtls_private_key: /etc/asterisk/keys/asterisk.key
                   dtls_cipher: NULL
                  dtls_ca_file: /etc/asterisk/keys/ca.crt
                  dtls_ca_path: NULL
                    dtls_setup: actpass
                   srtp_tag_32: NULL
                 media_address: NULL
               redirect_method: NULL
                       set_var: NULL
                     cos_audio: NULL
                     cos_video: NULL
               message_context: NULL
                     force_avp: yes
  media_use_received_transport: yes
                   accountcode: NULL
   media_encryption_optimistic: NULL
                 user_eq_phone: NULL
                rpid_immediate: NULL
             g726_non_standard: NULL
                 rtp_keepalive: NULL
                   rtp_timeout: NULL
              rtp_timeout_hold: NULL
     bind_rtp_to_media_address: NULL
           voicemail_extension: NULL
                          deny: NULL
                        permit: NULL
                           acl: NULL
                  contact_deny: NULL
                contact_permit: NULL
                   contact_acl: NULL
             subscribe_context: NULL
            fax_detect_timeout: NULL

mwi_subscribe_replaces_unsolicited: NULL

I most likely have missed something in the configuration, but it escapes me for now, so any suggestions are welcome.

We would need to see the complete SIP signaling and console output to understand what is going on here and why Asterisk is terminating the session.

Following is the partial log where the call starts until it finishes. (weird I thought I included this in a second post)
If required I can send the entire log. Is there a way to upload a file ?

PART 1

PART 2

Thank you for the input.

Nothing really sticks out, the log isn’t detailed enough. Can you enable debug and do “core set debug 9” and do it again?

Asterisk 13.10.2
pjproject 2.5.5
jansson 2.9
sipml 2.0.3

LOG DEBUG LEVEL 9 PART 1

LOG DEBUG LEVEL 9 PART 2

LOG DEBUG LEVEL 9 PART 3

LOG DEBUG LEVEL 9 PART 4

The only thing that sticks out is the fact that they are responding with “UDP/TLS/RTP/SAVPF” while we sent “RTP/SAVPF” for the media stream type. This could cause the SDP negotiation to fail. If you set “force_avp” to no our side will match theirs. Does that change anything?

Amazing, that fixed the problem on the WebRTC clients.
I will check other clients in the morning (It’s 23:00 here atm)

The setting is inherited from the chan_sip configuration, if I remember correctly it had to be set, though I might be wrong as I got this working over a year ago.

Thumbs up, you really know your stuff. I could have been trying configurations forever without your help.

Thanks again, everything looks to be OK.

Just one more question : is there an equivalent for SIPPEER dialplan function for PJSIP ?
I use this to check if the peer is registered prior to using the peer for outbound calls.

I would suggest using the DEVICE_STATE[1] dialplan function to know the state of it or using ChanIsAvail[2].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Function_DEVICE_STATE
[2] https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+Application_ChanIsAvail

I will give that a try.

DEVICE_STATE seems to do the trick, any status not UNAVAILABLE I regard as the peer being connected.