Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I get the headers of received CANCEL? #152

Closed
calvet27 opened this issue Jul 20, 2023 · 17 comments
Closed

Can I get the headers of received CANCEL? #152

calvet27 opened this issue Jul 20, 2023 · 17 comments

Comments

@calvet27
Copy link

calvet27 commented Jul 20, 2023

Hi,

Can I get the headsers of received CANCEL?
From SRF, We can listen the emitted event for canceled inbound request.

req.on('cancel', () => {
  // TODO something.
});

But we cannot get the headers of CANCEL from that way.
It is required to get some causes of firing CANCEL such as Reason header.

CANCEL sip:68050961695239@...:5060 SIP/2.0
From: "Jess Portugal"sip:*1139@...;tag=2aca825f-14fb3c5-1f1d3e-b89f53e0-45090a0a-13c4-759
To: sip:68050961695239@...
Call-ID: 2dca6bc8-127d3ab1-1f1d3e-afd33848-45090a0a-13c4-759
CSeq: 1 CANCEL
Via: SIP/2.0/UDP ...:5060;rport;branch=z9hG4bK-28d9f76a-1f1d3e-798a3bae-bb733988
Max-Forwards: 70
Supported: 100rel,timer,replaces
Reason: SIP ;cause=200 ;text="Call completed elsewhere
User-Agent: ...
Content-Length: 0

Please let me know how to get the headers.

@JSimoni42
Copy link
Contributor

It looks like this is where the CANCEL event is emitted:

obj.pendingNetworkInvites.get(callId).req.emit('cancel', sipMsg) ;
. You can get the headers from the SipMessage passed to the event listener

@calvet27
Copy link
Author

calvet27 commented Jul 20, 2023

@JSimoni42 ,

Thank you for your answer.
But I already tried to do that,

req.on('cancel', async (cancelReq) => {
...
});

But I think cancelReq.headers is not define.
Actually, I double checked that cancelReq is undefined in that case.
Is it a req object from CANCEL?

@davehorton
Copy link
Collaborator

@xquanluu can you comment? I think we just dealt with this requirement recently

@xquanluu
Copy link
Collaborator

xquanluu commented Jul 20, 2023

Take a look at this example:

expectCancel(uri) {
    this.srf.invite((req, res) => {
      req.on('cancel', (cancelReq) => {
        const headers = cancelReq.headers;
        console.log(headers);
      })
      this.srf.createB2BUA(req, res, uri)
        .then(({uas, uac}) => {
          throw new Error('unexpected dialog success - expected CANCEL from uac');
        })
        .catch((err) => {
          debug(`expectCancel: expected a final 487, got ${err}`);
          if (err.status === 487) return;
          throw err;
        });
    });
  }

Output:

{
via: 'SIP/2.0/UDP 172.29.0.2:5060;branch=z9hG4bK-1-1-0;rport=5060',
from: 'sipp sip:sipp@172.29.0.2:5060;tag=1SIPpTag001',
to: 'service sip:service@172.29.0.10:5060',
'call-id': '1-1@172.29.0.2-4',
cseq: '1 CANCEL',
reason: 'SIP;cause=200;text="Call completed elsewhere"',
'content-length': '0'
}

@xquanluu
Copy link
Collaborator

Not sure is what you are looking for? @calvet27

@xquanluu
Copy link
Collaborator

You may want to play with this testcase:
https://github.com/drachtio/drachtio-srf/blob/main/test/scripts/b2b.js#L24

@calvet27
Copy link
Author

@xquanluu

Can you give me version information about supporting cancelReq?

@xquanluu
Copy link
Collaborator

Can you use drachtio-srf: 4.5.28
drachtio-server: latest

@calvet27
Copy link
Author

@xquanluu

I use 4.4.18. After updating to 4.5.28, I will let you know the results.

@calvet27
Copy link
Author

@xquanluu

Can I get you tag information of the latest drachtio?
Is it same with 0.8.22?

@xquanluu
Copy link
Collaborator

Yes it's correct.

@calvet27
Copy link
Author

calvet27 commented Jul 25, 2023

@xquanluu
But it looks different.
0.8.22 does not give me cancel object but latest give me.
I updated drachtio-srf to 4.5.26.
Any advice?

@xquanluu
Copy link
Collaborator

Can you tell me how you build and deployed drachtio? via docker?

@calvet27
Copy link
Author

@xquanluu
Yes. I installed Drachtio SIP Server via Docker. The image is from Docker hub.
Drachtio

I had some tests to compare 0.8.22 and latest and then I noticed that the only the latest one worked properly.
cancelReq is undefined with 0.8.22 and Drachtio SRF 4.5.26 was used for both cases.

@xquanluu
Copy link
Collaborator

hmm. Strange but yes please use latest tag.,

0.8.2 was released 2 months ago, from that time up to now there is no official release yet.

@calvet27
Copy link
Author

calvet27 commented Jul 25, 2023

@xquanluu

I'm sorry to make you confused. Now 0.8.22 works properly.
Close this issue! Thank you for your support!

@xquanluu
Copy link
Collaborator

Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants