drachtio / drachtio-fsmrf

Drachtio freeswitch-based media resource function -- http://davehorton.github.io/drachtio-fsmrf
MIT License
47 stars 26 forks source link

Optional headers is not set when transport is ws #67

Closed spointer closed 1 year ago

spointer commented 1 year ago

Hello Dave,

I set optional headers to connectCaller function, these headers are not sent to freeswitch side when the SIP transport is wss. But if transport is udp, headers are sent as expected.

I could see the optional headers is ignored inside connectCaller function.

      if (!requiresDtlsHandshake(req.body)) {
        const endpoint = await this.createEndpoint({
          ...opts,
          remoteSdp: opts.remoteSdp || req.body,
          codecs: opts.codecs
        });
        const dialog = await this.srf.createUAS(req, res, {
          localSdp: endpoint.local.sdp,
          headers: opts.headers
        });
        callback(null, {endpoint, dialog}) ;
      }
      else {
        // scenario 2: SRTP is being used and therefore creating an endpoint
        // involves completing a dtls handshake with the originator
        const pair = {};
        const uuid = generateUuid() ;
        const family = opts.family || 'ipv4' ;
        const uri = `sip:drachtio@${this.sip[family]['udp'].address}`;

        /* set state of a pending connection (ie waiting for esl outbound connection) */
        this.pendingConnections.set(uuid, {});

        /* send invite to freeswitch */
        **this.srf.createUAC(uri, {
          headers: {
            'User-Agent': `drachtio-fsmrf:${uuid}`,
            'X-esl-outbound': `${this.advertisedAddress}:${this.advertisedPort}`
          }**,
          localSdp: req.body
        }, {}, (err, dlg) => {

Could you consider fixing this? Thanks.

spointer commented 1 year ago

Actually it seems that SDP is not required DTLS, optional headers are set when createUAC is called inside createEndpoint function but if required DTLS, optional headers are ignored.

spointer commented 1 year ago

Thanks for merging, i close this issue.

davehorton commented 1 year ago

this fix is released in drachtio-fsmrf@3.0.17