google-code-export / rtmplite

Automatically exported from code.google.com/p/rtmplite
3 stars 1 forks source link

Problems with BYE command from siprtmp side #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have a following configuration:
a web phone with javascript interface based on flash-videoio.
That web phone uses a rtmplite + p2p-sip as rtmp server.

The problem happens when i try to cancel an outbound call from web phone side. 
It does not get cancelled, and destination phone continues ringing.

This problem exists in last (r96) vesion of rtmplite, in siprtmp and 
siprtmp-gevent both.
In old version (r83), the problem does not exists in siprtmp, but exists in 
siprtmp-gevent.

Please help us to fix this problem because its really important to have an 
ability to cancel an outbound call.

Let me try to describe a session in steps:

1. I make connection with rtmp server: phoneObject.setProperty('src', "rtmp://" 
+ sipServer + "/sip/" + sipUser + "?rate=" + rate +
    "&bidirection=true" + "&arg=" + sipAuthname + "&arg=" + sipAuthpass +
    "&arg=" + sipDisplayname + "&arg=" + rate_name);

2. When connection is made, i catch a event onPropertyChange. Here i have 
phoneObject.src set - this means connection is made.

in rtmp log, i see successful registration:
========
receivedResponse response= 200  for ua with queue
response put in the ua queue
received response success
  registration returned success None
  register successful
========

3. I make a call with invite command: phoneObject.callProperty('call', 
'invite', 'sip:number@my_provider.com');

rtmp-invite sip:+79201214332@brm-sip.binatel.ru
createClient <UserAgent call-id=4346893@77.108.78.93>
sending[656] to ('77.108.78.91', 5060)
INVITE sip:+79201214332@brm-sip.binatel.ru SIP/2.0
......

4. After some time, a destination phone starts ringing. 

5. Then, i try to cancel an outbound call _before_ a destination phone will 
accept it:
              phoneObject.callProperty('call', 'bye');
              phoneObject.setProperty('publish', null);
              phoneObject.setProperty('play', null);

in log, i see this:
================
rtmp-bye
  cancel outbound invite .. 
================
but, the phone continues ringing, and, i don't see a SIP CANCEL command on the 
SIP side!

rtmp_bye function does this:
===
            if self.session is None and self.outgoing is not None: # pending outgoing invite
                if _debug: print '  cancel outbound invite'
                self.outgoing.close()
===
So, no session there...
In rtmp_invite function, using some print expressions for trace, i see that 
execution of rtmp_invite stops at:
===
session, reason = yield self.outgoing
===
it waits call accepting or smth like this...

6. I accept a phone call by destination phone.
Then, BYE command is ignored, but, web phone state is invalid, because my 
script switches to "call inactive" state, and does not catch "accepted" event.

But, if i use siprtmp_gevent, i see a funny things here:
when i call rtmp-bye on rtmp server, i see in the logs:

=== call rtmp-bye from web-client side ==
nothing in logs.. i dont see a "rtmp-bye" record...

=== accept a call on dest phone ===
here i see a record about "rtmp-bye":

rtmp-bye
sending[454] to ('77.108.78.91', 5060)
BYE sip:79201214332@77.108.78.90:5060 SIP/2.0
....

and, call is closed.

==================================
I think, the correct behaviour should be sending SIP CANCEL to sip server when 
rtmp-bye command tries to cancel outbound (not accepted yet) call.

Here i attach full logs of 4 runs:
siprtmp_new_log_bye_before_press.log - session started, outbound call made, 
rtmp-bye command invoked, server stopped

siprtmp_new_log_bye_with_press.log - session started, outbound call made, 
rtmp-bye command invoked, call accepted by destination phone, server stopped

siprtmp_gevent_new_bye_before_press.log, siprtmp_gevent_new_bye_with_press.log 
- the save for gevent version.

Original issue reported on code.google.com by eag...@gmail.com on 18 Aug 2011 at 1:22

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in svn r97.

The bug got introduced in r91 when I added propagation of 180/183 events to web 
client, but forgot to re-assign self.outgoing to new task/generator of 
continueConnect instead of old connect. So doing self.outgoing.close() was not 
having any effect because the old task/generator was already closed.

Original comment by kundan10 on 18 Aug 2011 at 7:11

GoogleCodeExporter commented 9 years ago
Hi Kundan!
I checked r97, but, siprtmp_gevent is not fixeed there.
Please fix gevent version too to have call cancellation working completely...

Original comment by eag...@gmail.com on 19 Aug 2011 at 12:55

GoogleCodeExporter commented 9 years ago
Fixed gevent version in svn r98. This was a different issue though. Thanks for 
pointing out...

Original comment by kundan10 on 19 Aug 2011 at 8:43

GoogleCodeExporter commented 9 years ago
Hi Kundan!
The problem still exists in siprtmp.py (not siprtmp_gevent.py):

When i make a call with INVITE command, and try to cancel it immidiately, then, 
no cancel happens:

sending[918] to ('77.108.78.91', 5060)
INVITE sip:+79201214332@brm-sip.binatel.ru SIP/2.0
Call-ID: 517708372@77.108.78.93
........

received[359] from ('77.108.78.91', 5060)
SIP/2.0 100 trying -- your call is important to us
Call-ID: 517708372@77.108.78.93
Via: SIP/2.0/UDP 77.108.78.93:16560;rport=16560;
.......

receivedResponse response= 100  for ua with queue
response put in the ua queue
rtmp-bye
  cancel outbound invite

received[885] from ('77.108.78.91', 5060)
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 
77.108.78.93:16560;rport=16560;branch=z9hG4bKV1z4MycoPMJacIMlL_RlHw..
Record-Route: <sip:77.108.78.91;lr=on;ftag=189372003423>
From: "BEBEBE" <sip:test_asterisk_login@brm-sip.binatel.ru>;tag=189372003423
CSeq: 2 INVITE
.............

receivedResponse response= 183  for ua with queue
response put in the ua queue
  exception in invite (<type 'exceptions.TypeError'>, TypeError("'NoneType' object is not iterable",), <traceback object at 0x969af04>)
Gateway[0] onResult <amf._Undefined object at 0xb7e8dcec>
received[871] from ('77.108.78.91', 5060)
SIP/2.0 200 OK
Via: SIP/2.0/UDP 
77.108.78.93:16560;rport=16560;branch=z9hG4bKV1z4MycoPMJacIMlL_RlHw..
Record-Route: <sip:77.108.78.91;lr=on;ftag=189372003423>

...........

As you can see, no CANCEL command has been sent to SIP server.

But, if i cancel a call (send BYE command) after phone will start ringing, 
then, CANCEL command has been sent to SIP server:

==================================================================
sending[918] to ('77.108.78.91', 5060)
INVITE sip:+79201214332@brm-sip.binatel.ru SIP/2.0
Call-ID: 1935789688@77.108.78.93

...
received[359] from ('77.108.78.91', 5060)
SIP/2.0 100 trying -- your call is important to us
Call-ID: 1935789688@77.108.78.93
Via: SIP/2.0/UDP 
77.108.78.93:38965;rport=38965;branch=z9hG4bKhN1R185KykadWXy3auAD0w..
From: "BEBEBE" <sip:test_asterisk_login@brm-sip.binatel.ru>;tag=11402477540
........

receivedResponse response= 100  for ua with queue
response put in the ua queue
received[886] from ('77.108.78.91', 5060)
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 
77.108.78.93:38965;rport=38965;branch=z9hG4bKhN1R185KykadWXy3auAD0w..

..........
rtmp-bye
  cancel outbound invite

..........
sending[325] to ('77.108.78.91', 5060)
CANCEL sip:+79201214332@brm-sip.binatel.ru SIP/2.0
Content-Length: 0
Via: SIP/2.0/UDP 77.108.78.93:38965;rport;branch=z9hG4bKhN1R185KykadWXy3auAD0w..
From: "BEBEBE" <sip:test_asterisk_login@brm-sip.binatel.ru>;tag=11402477540

received[372] from ('77.108.78.91', 5060)
SIP/2.0 200 canceling
Via: SIP/2.0/UDP 77.108.78.93:38965;rport=38965;
22.08 12:42:58    
....

received[465] from ('77.108.78.91', 5060)
SIP/2.0 487 Request Terminated
.....
receivedResponse response= 487  for ua with queue
response put in the ua queue
  exception in invite (<type 'exceptions.TypeError'>, TypeError("'NoneType' object is not iterable",), <traceback object at 0x8797cac>)
Gateway[0] onResult <amf._Undefined object at 0xb7e76cec>

========================
In siprtmp_gevent.py, this problem does not exists: CANCEL command is sent 
before phone starts ringing, or after - doesnt matters...

Original comment by eag...@gmail.com on 22 Aug 2011 at 8:51

GoogleCodeExporter commented 9 years ago

Original comment by kundan10 on 23 Aug 2011 at 11:28

GoogleCodeExporter commented 9 years ago
Fixed in r97 and r98.

Original comment by kundan10 on 20 Sep 2011 at 5:42