LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-26-2017, 06:23 AM   #1
maduino
LQ Newbie
 
Registered: Jun 2016
Posts: 5

Rep: Reputation: Disabled
Problems with cancelling a SIP "call"


Hi,

I want to ring my IP phone. Therefore I wrote a simple PHP script which talks to my VoIP router. The phone rings as it should but when I send the "CANCEL" request the router always answers with "481 Call Leg/Transaction Does Not Exist" and the phone continues ringing. I check the Call-ID, CSeq and other ids a dozen times but everything seems to match. I also tried a "normal" VoIP client software, captured the data with Wireshark and compared them and found nothing wrong.

Does anyone have an idea where my mistake is? You'll find the complete data below. The router has IP 192.168.0.1 and the calling device has IP 192.168.0.2. The number "**100" is called (internal number).

Regards!

Code:
---- SENDING ----
INVITE sip:**100@192.168.0.1 SIP/2.0
Call-ID: 1319899383
CSeq: 1 INVITE
Max-Forwards: 70
From: "frank" <sip:frank@192.168.0.1>;tag=831859804
Via: SIP/2.0/UDP 192.168.0.2:5060; branch=30b863aa5f9597a118184e78f0646663;rport
To: <sip:**100@192.168.0.1>
Contact: "frank" <sip:frank@192.168.0.2:5060;transport=udp>
Content-Type: application/sdp
Content-Length: 0
----------------

    ---- RESPONSE (192.168.0.1 : 5060) ----
    SIP/2.0 401 Unauthorized
    Via: SIP/2.0/UDP 192.168.0.2:5060;branch=30b863aa5f9597a118184e78f0646663;rport=5060
    From: "frank" <sip:frank@192.168.0.1>;tag=831859804
    To: <sip:**100@192.168.0.1>;tag=7746866CE2755421
    Call-ID: 1319899383
    CSeq: 1 INVITE
    WWW-Authenticate: Digest realm="fritz.box", nonce="487B9755959CA211"
    User-Agent: FRITZ!OS
    Content-Length: 0
    ----------

---- SENDING ----
ACK sip:**100@192.168.0.1 SIP/2.0
Call-ID: 1319899383
CSeq: 1 ACK
Max-Forwards: 70
From: "frank" <sip:frank@192.168.0.1>;tag=831859804
Via: SIP/2.0/UDP 192.168.0.2:5060; branch=30b863aa5f9597a118184e78f0646663;rport
To: <sip:**100@192.168.0.1>
Content-Length: 0
---------------

---- SENDING ----
INVITE sip:**100@192.168.0.1 SIP/2.0
Call-ID: 1319899383
CSeq: 2 INVITE
Max-Forwards: 70
From: "frank" <sip:frank@192.168.0.1>;tag=831859804
Via: SIP/2.0/UDP 192.168.0.2:5060; branch=30b863aa5f9597a118184e78f0646663;rport
To: <sip:**100@192.168.0.1>
Contact: "frank" <sip:frank@192.168.0.2:5060;transport=udp>
Content-Type: application/sdp
Authorization: Digest username="frank", realm="fritz.box", nonce="487B9755959CA211", uri="sip:**100@192.168.0.1", response="edf..."
Content-Length: 0
---------------

    ---- RESPONSE (192.168.0.1 : 5060) ----
    SIP/2.0 100 Trying
    Via: SIP/2.0/UDP 192.168.0.2:5060;branch=30b863aa5f9597a118184e78f0646663;rport=5060
    From: "frank" <sip:frank@192.168.0.1>;tag=831859804
    To: <sip:**100@192.168.0.1>
    Call-ID: 1319899383
    CSeq: 2 INVITE
    User-Agent: AVM FRITZ!Box
    Content-Length: 0
    ----------

    ---- RESPONSE (192.168.0.1 : 5060) ----
    SIP/2.0 183 Session Progress
    Via: SIP/2.0/UDP 192.168.0.2:5060;branch=30b863aa5f9597a118184e78f0646663;rport=5060
    From: "frank" <sip:frank@192.168.0.1>;tag=831859804
    To: <sip:**100@192.168.0.1>;tag=3812AB5062EEB99C
    Call-ID: 1319899383
    CSeq: 2 INVITE
    Contact: <sip:8C3E39F1BF28E5EA45607813E6C96@192.168.0.1>
    User-Agent: AVM FRITZ!Box
    Content-Type: application/sdp
    Content-Length: 355

    ...
    ----------

---- SENDING ----
CANCEL sip:**100@192.168.0.1 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.2:5060;branch=30b863aa5f9597a118184e78f0646663;rport
From: "frank" <sip:frank@192.168.0.1>;tag=831859804
To: <sip:**100@192.168.0.1>
Call-ID: 1319899383
CSeq: 2 CANCEL
Content-Length: 0
---------------

    ---- RESPONSE (192.168.0.1 : 5060) ----
    SIP/2.0 481 Call Leg/Transaction Does Not Exist
    Via: SIP/2.0/UDP 192.168.0.2:5060;branch=30b863aa5f9597a118184e78f0646663;rport=5060
    From: "frank" <sip:frank@192.168.0.1>;tag=831859804
    To: <sip:**100@192.168.0.1>
    Call-ID: 1319899383
    CSeq: 2 CANCEL
    User-Agent: FRITZ!OS
    Content-Length: 0
    ----------
 
Old 08-30-2017, 03:52 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,667
Blog Entries: 6

Rep: Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531Reputation: 2531
I have zero knowledge of SIP protocol, but as no one else has stepped up I will offer the results of my own quick search.

Using the search term "481 Call Leg/Transaction Does Not Exist" as a starting point and DuckDuckGo search engine, I find many potentially helpful pages. This one from asterisk.org stands out as applicable on a quick scan, from which:

Quote:
I looked over the RFC 3261 and saw that
"The following procedures are used to construct a CANCEL request. The
Request-URI, Call-ID, To, the numeric part of CSeq, and From header
fields in the CANCEL request MUST be identical to those in the
request being cancelled, including tags. ..."
Those headers differ between the initial INVITE and the CANCEL requests in your example.

As there appears to be a shortage of SIP programmers participating here, you may get better response from any active VoIP forum - there appear to be many!

Good luck!

Last edited by astrogeek; 08-30-2017 at 04:00 PM. Reason: typo
 
1 members found this post helpful.
Old 12-31-2017, 11:00 AM   #3
aurelian_15
LQ Newbie
 
Registered: Dec 2017
Posts: 4

Rep: Reputation: Disabled
Just ran into exactly the same problem while trying to ring all phones connected to a Fritz!Box in response to an home-automation event. The solution is to prefix the "branch" id with the magic cookie "z9hG4bK" to signal compliance with the specification.

See https://github.com/astoeckel/femtosi...er/femtosip.py for a working example.
 
  


Reply

Tags
call, ip, phone, sip, voip


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
where is input_handler's call back function "event" and "connect" called georgewhr Programming 0 04-19-2014 09:44 AM
php "system"-call to access tty port, "error accessing" wedz Linux - Software 3 05-22-2012 07:34 PM
Qt "cannot call constructor for""a function-style cast remove the redundant ::QBrush" Peterius Linux - Software 4 11-24-2010 04:57 PM
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 01:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration