Rewrite_contact webrtc not working

Hi,

I’m doing some tests with a WebRTC application, this application links the Contact header to a session, but when asterisk send an OK after the REGISTER it change the contact header with a local IP.

After a few search I find the rewrite_contact option who should disable this functionality but It’s not working for me .

What I did wrong ?

PJSIP endpoint configuration :

 Endpoint:  <Endpoint/CID.....................................>  <State.....>  <Channels.>
    I/OAuth:  <AuthId/UserName...........................................................>
        Aor:  <Aor............................................>  <MaxContact>
      Contact:  <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>
  Transport:  <TransportId........>  <Type>  <cos>  <tos>  <BindAddress..................>
   Identify:  <Identify/Endpoint.........................................................>
        Match:  <criteria.........................>
    Channel:  <ChannelId......................................>  <State.....>  <Time.....>
        Exten: <DialedExten...........>  CLCID: <ConnectedLineCID.......>
==========================================================================================

 Endpoint:  rev-asterisk-18.ARvlNZba/0                           Unavailable   0 of inf
     InAuth:  rev-asterisk-18.ARvlNZba/rev-asterisk-18.ARvlNZba
        Aor:  rev-asterisk-18.ARvlNZba                           1
  Transport:  wss_443                   wss      0      0  0.0.0.0:5060


 ParameterName                          : ParameterValue
 =======================================================================================================
 100rel                                 : yes
 accept_multiple_sdp_answers            : false
 accountcode                            : 
 acl                                    : 
 aggregate_mwi                          : true
 allow                                  : (alaw)
 allow_overlap                          : true
 allow_subscribe                        : true
 allow_transfer                         : true
 aors                                   : rev-asterisk-18.ARvlNZba
 asymmetric_rtp_codec                   : false
 auth                                   : rev-asterisk-18.ARvlNZba
 bind_rtp_to_media_address              : false
 bundle                                 : true
 call_group                             : 
 callerid                               : "Anonymous" <0>
 callerid_privacy                       : allowed_not_screened
 callerid_tag                           : 
 codec_prefs_incoming_answer            : prefer:pending, operation:intersect, keep:all, transcode:allow
 codec_prefs_incoming_offer             : prefer:pending, operation:intersect, keep:all, transcode:allow
 codec_prefs_outgoing_answer            : prefer:pending, operation:intersect, keep:all, transcode:allow
 codec_prefs_outgoing_offer             : prefer:pending, operation:union, keep:all, transcode:allow
 connected_line_method                  : invite
 contact_acl                            : 
 context                                : rev-asterisk-18_BE_no_restrictions_includes
 cos_audio                              : 0
 cos_video                              : 0
 device_state_busy_at                   : 0
 direct_media                           : false
 direct_media_glare_mitigation          : none
 direct_media_method                    : invite
 disable_direct_media_on_nat            : false
 dtls_auto_generate_cert                : Yes
 dtls_ca_file                           : 
 dtls_ca_path                           : 
 dtls_cert_file                         : 
 dtls_cipher                            : 
 dtls_fingerprint                       : SHA-256
 dtls_private_key                       : 
 dtls_rekey                             : 0
 dtls_setup                             : actpass
 dtls_verify                            : Yes
 dtmf_mode                              : rfc4733
 fax_detect                             : false
 fax_detect_timeout                     : 0
 follow_early_media_fork                : true
 force_avp                              : false
 force_rport                            : true
 from_domain                            : 
 from_user                              : 
 g726_non_standard                      : false
 ice_support                            : true
 identify_by                            : username,auth_username
 ignore_183_without_sdp                 : false
 inband_progress                        : true
 incoming_call_offer_pref               : local
 incoming_mwi_mailbox                   : 
 language                               : en_US_replicant
 mailboxes                              : 
 max_audio_streams                      : 1
 max_video_streams                      : 1
 media_address                          : 
 media_encryption                       : dtls
 media_encryption_optimistic            : false
 media_use_received_transport           : true
 message_context                        : 
 moh_passthrough                        : false
 moh_suggest                            : default
 mwi_from_user                          : 
 mwi_subscribe_replaces_unsolicited     : no
 named_call_group                       : rev-asterisk-18
 named_pickup_group                     : rev-asterisk-18
 notify_early_inuse_ringing             : false
 one_touch_recording                    : false
 outbound_auth                          : 
 outbound_proxy                         : 
 outgoing_call_offer_pref               : remote_merge
 pickup_group                           : 
 preferred_codec_only                   : false
 record_off_feature                     : automixmon
 record_on_feature                      : automixmon
 refer_blind_progress                   : true
 rewrite_contact                        : false
 rpid_immediate                         : false
 rtcp_mux                               : true
 rtp_engine                             : asterisk
 rtp_ipv6                               : false
 rtp_keepalive                          : 0
 rtp_symmetric                          : true
 rtp_timeout                            : 60
 rtp_timeout_hold                       : 1200
 sdp_owner                              : -
 sdp_session                            : ALLOcloud v3.1
 send_connected_line                    : yes
 send_diversion                         : true
 send_history_info                      : false
 send_pai                               : false
 send_rpid                              : false
 srtp_tag_32                            : false
 stir_shaken                            : false
 sub_min_expiry                         : 0
 subscribe_context                      : 
 suppress_q850_reason_headers           : false
 t38_udptl                              : true
 t38_udptl_ec                           : redundancy
 t38_udptl_ipv6                         : false
 t38_udptl_maxdatagram                  : 0
 t38_udptl_nat                          : true
 timers                                 : yes
 timers_min_se                          : 90
 timers_sess_expires                    : 1800
 tone_zone                              : 
 tos_audio                              : 0
 tos_video                              : 0
 transport                              : wss_443
 trust_connected_line                   : yes
 trust_id_inbound                       : false
 trust_id_outbound                      : false
 use_avpf                               : true
 use_ptime                              : false
 user_eq_phone                          : false
 voicemail_extension                    : 
 webrtc                                 : yes

and the trace where the OK is still change :

<--- Received SIP request (619 bytes) from WS:127.0.0.1:49448 --->
REGISTER sip:rev-asterisk-18.***** SIP/2.0
Via: SIP/2.0/WSS 2cqr82sgl21d.invalid;branch=z9hG4bK8334519
Max-Forwards: 70
To: <sip:rev-asterisk-18.ARvlNZba@rev-asterisk-18.*****>
From: <sip:rev-asterisk-18.ARvlNZba@rev-asterisk-18.*******>;tag=b7thida5bp
Call-ID: b6kg6v79ubogbvst587pak
CSeq: 81 REGISTER
Contact: <sip:tjsfdi79@2cqr82sgl21d.invalid;transport=ws>;reg-id=1;+sip.instance="<urn:uuid:ab9d1f82-85f8-4b1b-9332-1fdcec7ad933>";expires=30
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: path, gruu, outbound

Content-Length: 0


<--- Transmitting SIP response (551 bytes) to WS:127.0.0.1:49448 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WSS 2cqr82sgl21d.invalid;rport=49448;received=127.0.0.1;branch=z9hG4bK8334519
Call-ID: b6kg6v79ubogbvst587pak
From: <sip:rev-asterisk-18.ARvlNZba@rev-asterisk-18.****>;tag=b7thida5bp
To: <sip:rev-asterisk-18.ARvlNZba@rev-asterisk-18.*****>;tag=z9hG4bK8334519
CSeq: 81 REGISTER
WWW-Authenticate: Digest realm="rev-asterisk-18.*****",nonce="1620295344/648daba0558e837e95649efbdcbbf965",opaque="0f7a70b52d32ccfa",algorithm=md5,qop="auth"

Content-Length:  0


<--- Received SIP request (944 bytes) from WS:127.0.0.1:49448 --->
REGISTER sip:rev-asterisk-18.***** SIP/2.0
Via: SIP/2.0/WSS 2cqr82sgl21d.invalid;branch=z9hG4bK1358931
Max-Forwards: 70
To: <sip:rev-asterisk-18.ARvlNZba@rev-asterisk-18.****>
From: <sip:rev-asterisk-18.ARvlNZba@rev-asterisk-18.****>;tag=b7thida5bp
Call-ID: b6kg6v79ubogbvst587pak
CSeq: 82 REGISTER
Authorization: Digest algorithm=MD5, username="rev-asterisk-18.ARvlNZba", realm="rev-asterisk-18.****", nonce="1620295344/648daba0558e837e95649efbdcbbf965", uri="sip:rev-asterisk-18.a*****", response="69b8496aec1af1a4cb4dd1d747db2a26", opaque="0f7a70b52d32ccfa", qop=auth, cnonce="evol5cgensji", nc=00000001
Contact: <sip:tjsfdi79@2cqr82sgl21d.invalid;transport=ws>;reg-id=1;+sip.instance="<urn:uuid:ab9d1f82-85f8-4b1b-9332-1fdcec7ad933>";expires=30
Allow: ACK,CANCEL,INVITE,MESSAGE,BYE,OPTIONS,INFO,NOTIFY,REFER
Supported: path, gruu, outbound

Content-Length: 0


    -- Added contact 'sip:tjsfdi79@127.0.0.1:49448;transport=ws' to AOR 'rev-asterisk-18.ARvlNZba' with expiration of 60 seconds
<--- Transmitting SIP response (476 bytes) to WS:127.0.0.1:49448 --->
SIP/2.0 200 OK
Via: SIP/2.0/WSS 2cqr82sgl21d.invalid;rport=49448;received=127.0.0.1;branch=z9hG4bK1358931
Call-ID: b6kg6v79ubogbvst587pak
From: <sip:rev-asterisk-18.ARvlNZba@rev-asterisk-18****>;tag=b7thida5bp
To: <sip:rev-asterisk-18.ARvlNZba@rev-asterisk-18****>;tag=z9hG4bK1358931
CSeq: 82 REGISTER
Date: Thu, 06 May 2021 10:02:24 GMT
Contact: <sip:tjsfdi79@127.0.0.1:49448;transport=ws>;expires=59
Content-Length:  0

Any clue is welcome .

Thanks

Websockets always rewrite the Contact[1], to ensure that the existing Websocket connection is reused in PJSIP for any traffic to the endpoint.

[1] asterisk/res_pjsip_transport_websocket.c at master · asterisk/asterisk · GitHub

Hi,

Thanks for the answer, I guess it also why it generate 2 contact header when I try to use the contact AOR option .

I guess I will do the other way around and fix the contact with the local websocket port .

Thanks

My impression is that you are trying to obtain information from Contact that it simply isn’t intended to provide.

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