kirm / sip.js

Session Initiation Protocol for node.js
MIT License
427 stars 171 forks source link

How to send 'CANCEL'? #138

Closed hslee0429 closed 4 years ago

hslee0429 commented 4 years ago

I just want to make a 'CANCEL' when I receive '180' or '183' response. I tried to make 'CANCEL' like below, but it does not work. (CANCEL request was not sent)

sip.send({ method: 'CANCEL', uri: 'sip:'+toNumber+'@'+sipIP+':'+sipPort, headers: { to: rs.headers.to, from: rs.headers.from, 'call-id': rs.headers['call-id'], 'max-forwards': 70, cseq: {method: 'CANCEL', seq: rs.headers.cseq.seq}, } });

kirm commented 4 years ago

There is an example of sending CANCEL in proxy.js.

Basically you need to wait for a provisional response from the server, and send cancel using 'Via' header from that response.

hslee0429 commented 4 years ago

I solved this problem by attaching VIA. Thank you.

sip.send({ method: 'CANCEL', uri: 'sip:'+toNumber+'@'+sipIP+':'+sipPort, headers: { to: rs.headers.to, from: rs.headers.from, 'call-id': rs.headers['call-id'], 'max-forwards': 70, cseq: {method: 'CANCEL', seq: rs.headers.cseq.seq}, via: [rs.headers.via[0]] } });