Asterisk: PJSIP_HEADER and Websocket



调用客户端的webrtc时,我需要添加自定义标头。由星号 13 + siphtml5 使用。拨号计划:

exten => 198,1,Answer()
same => n,Set(PJSIP_HEADER(add,X-DRP)=71234567890)
same => n,DIAL(PJSIP/${EXTEN})

星号日志:

Connected to Asterisk 13.17.2 currently running on ubuntu-xenial (pid = 8895)
  == WebSocket connection from '192.168.0.44:58096' forcefully closed due to fatal write error
  == WebSocket connection from '192.168.0.44:58595' for protocol 'sip' accepted using version '13'
    -- Added contact 'sip:a9gn89sg@192.168.0.44:58595;transport=ws' to AOR '199' with expiration of 450 seconds
  == Contact 199/sip:a9gn89sg@192.168.0.44:58595;transport=ws has been created
  == Contact 199/sip:3qogi2fo@192.168.0.44:58096;transport=ws has been deleted
    -- Contact 199/sip:a9gn89sg@192.168.0.44:58595;transport=ws is now Unknown.  RTT: 0.000 msec
  == Setting global variable 'SIPDOMAIN' to 'aster13'
  == DTLS ECDH initialized (automatic), faster PFS enabled
    -- Executing [198@default:1] Answer("PJSIP/199-00000008", "") in new stack
       > 0x7f0ea0071960 -- Strict RTP learning after remote address set to: 123.135.239.111:58827
[Oct 23 16:02:31] ERROR[8943]: pjproject:0 <?>:            icess0x7f0ea000ce18 ..Error sending STUN request: Network is unreachable
[Oct 23 16:02:31] ERROR[8943]: pjproject:0 <?>:            icess0x7f0ea000ce18 ..Error sending STUN request: Network is unreachable
       > 0x7f0ea0071960 -- Strict RTP learning after ICE completion
       > 0x7f0ea0071960 -- Strict RTP switching to RTP target address 192.168.100.97:58827 as source
    -- Executing [198@default:2] SIPAddHeader("PJSIP/199-00000008", "X-DRP: 79161234567") in new stack
    -- Executing [198@default:3] Set("PJSIP/199-00000008", "PJSIP_HEADER(add,X-DRP)=79161234567") in new stack
    -- Executing [198@default:4] Verbose("PJSIP/199-00000008", "Set(OldContact="199" <sips:199@192.168.100.97:54514;transport=ws;rtcweb-breaker=no;click2call=no>;+g.oma.sip-im;language="en,fr")") in new stack
Set(OldContact=199 <sips:199@192.168.100.97:54514;transport=ws;rtcweb-breaker=no;click2call=no>;+g.oma.sip-im;language=en,fr)
    -- Executing [198@default:5] Dial("PJSIP/199-00000008", "PJSIP/198") in new stack
    -- Called PJSIP/198
    -- PJSIP/199-00000008 requested media update control 26, passing it to PJSIP/198-00000009
  == DTLS ECDH initialized (automatic), faster PFS enabled
    -- PJSIP/198-00000009 is ringing
       > 0x7f0ea0071960 -- Strict RTP learning complete - Locking on source address 192.168.100.97:58827
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [198@default:7] Hangup("PJSIP/199-00000008", "") in new stack
  == Spawn extension (default, 198, 7) exited non-zero on 'PJSIP/199-00000008'
    -- Added contact 'sips:199@192.168.100.97:54514;transport=ws;rtcweb-breaker=no' to AOR '199' with expiration of 200 seconds
  == Contact 199/sips:199@192.168.100.97:54514;transport=ws;rtcweb-breaker=no has been created
  == Contact 199/sip:a9gn89sg@192.168.0.44:58595;transport=ws has been deleted
    -- Contact 199/sips:199@192.168.100.97:54514;transport=ws;rtcweb-breaker=no is now Unknown.  RTT: 0.000 msec

而且我在浏览器的调试日志中找不到标头 X-DRP:

recv=INVITE sips:198@192.168.100.97:54445;transport=ws;rtcweb-breaker=no SIP/2.0
Via: SIP/2.0/WSS 192.168.100.97:54445;rport;branch=z9hG4bKPja4ca4b5b-62c2-4953-a761-d13d34696007;alias
From: "199"<sip:199@ubuntu-xenial>;tag=a1b0c71d-f89b-4226-a84e-82e7db8b2b21
To: <sips:198@192.168.100.97;rtcweb-breaker=no>
Contact: <sips:asterisk@ubuntu-xenial:5060;transport=ws>
Call-ID: a47911b2-c6d4-4222-961b-f0418a4e00c0
CSeq: 30108 INVITE
Content-Type: application/sdp
Content-Length: 1085
Allow: OPTIONS,SUBSCRIBE,NOTIFY,PUBLISH,INVITE,ACK,BYE,CANCEL,UPDATE,PRACK,REGISTER,MESSAGE,REFER
Supported: 100rel,timer,replaces,norefersub
Session-Expires: 1800;refresher=uac
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 13.17.2

v=0
o=- 780155122 780155122 IN IP4 192.168.49.32
s=Asterisk
c=IN IP4 192.168.49.32
t=0 0
m=audio 15018 UDP/TLS/RTP/SAVPF 0 101
a=connection:new
a=setup:actpass
a=fingerprint:SHA-256 AA:94:9A:8F:24:9A:BD:C2:6B:BA:57:4D:E2:D3:1F:1E:B1:F9:87:B1:96:C7:29:93:B8:75:16:D6:73:9D:1E:3E
a=ice-ufrag:3e3de33532c2fcdc32d71b2f086be032
a=ice-pwd:78e4b4b93a861933107a205a10cac6dd
a=candidate:Hc92a8000 1 UDP 2130706431 fe80::14:68ff:fe3e:8447 15018 typ host
a=candidate:H6893915f 1 UDP 2130706431 fe80::a00:27ff:feeb:a9e 15018 typ host
a=candidate:Ha00020f 1 UDP 2130706431 10.0.2.15 15018 typ host
a=candidate:Hc0a83120 1 UDP 2130706431 192.168.49.32 15018 typ host
a=candidate:Hc92a8000 2 UDP 2130706430 fe80::14:68ff:fe3e:8447 15019 typ host
a=candidate:H6893915f 2 UDP 2130706430 fe80::a00:27ff:feeb:a9e 15019 typ host
a=candidate:Ha00020f 2 UDP 2130706430 10.0.2.15 15019 typ host
a=candidate:Hc0a83120 2 UDP 2130706430 192.168.49.32 15019 typ host
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
a=rtcp-mux

PJSIP是否支持WebSocket的PJSIP_HEADER?有没有其他方法可以将自定义标头添加到webrtc客户端的INVOTE中?

我使用星号13和siphtml5 Web客户端。此外,我使用wireshark检查wss流量,对其进行解密,但仍然找不到X-DRP标头。

在星号设置标题中使用:

same => n,SIPAddHeader(HEADERNAME: ${SOMEVAR})

您需要在客户端中使用更新的库,例如 jsSip。在这种情况下,您无法像这样获取服务器标头:

phone.on('newRTCSession', function(e){
   if (e.originator == 'remote') {
       console.log(e.request.headers);
   }
});

相关内容

  • 没有找到相关文章

最新更新