flutter-webrtc/dart-sip-ua

Call Refer Failing

Vinayak006 opened this issue · 0 comments

Describe the bug
When making call refer, Refer failed with below error

E/flutter (12711): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type '(RTCSession) => Null' is not a subtype of type '(RTCSession) => bool' of 'initCallback'
E/flutter (12711): #0      _TypeError._throwNew (dart:core-patch/errors_patch.dart:105:68)
E/flutter (12711): #1      SIPUAHelper._options.<anonymous closure> (package:sip_ua/src/sip_ua_helper.dart:296:19)
E/flutter (12711): #2      EventManager.emit (package:sip_ua/src/event_manager/event_manager.dart:109:17)
E/flutter (12711): #3      RTCSession._receiveRefer (package:sip_ua/src/rtc_session.dart:2085:5)
E/flutter (12711): #4      RTCSession._receiveRequest (package:sip_ua/src/rtc_session.dart:1348:13)
E/flutter (12711): #5      Dialog.receiveRequest (package:sip_ua/src/dialog.dart:168:26)
E/flutter (12711): #6      UA.receiveRequest (package:sip_ua/src/ua.dart:736:16)
E/flutter (12711): #7      UA.onTransportData (package:sip_ua/src/ua.dart:963:7)
E/flutter (12711): #8      Transport._onData (package:sip_ua/src/transport.dart:299:11)
E/flutter (12711): #9      WebSocketInterface._onMessage (package:sip_ua/src/transports/websocket_interface.dart:178:16)
E/flutter (12711): #10     WebSocketInterface.connect.<anonymous closure> (package:sip_ua/src/transports/websocket_interface.dart:99:9)
E/flutter (12711): #11     WebSocketImpl.connect.<anonymous closure> (package:sip_ua/src/transports/websocket_dart_impl.dart:38:20)
E/flutter (12711): #12     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
E/flutter (12711): #13     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (12711): #14     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (12711): #15     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
E/flutter (12711): #16     _StreamController._add (dart:async/stream_controller.dart:658:7)
E/flutter (12711): #17     _StreamController.add (dart:async/stream_controller.dart:606:5)
E/flutter (12711): #18     new _WebSocketImpl._fromSocket.<anonymous closure> (dart:_http/websocket_impl.dart:1144:21)
E/flutter (12711): #19     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
E/flutter (12711): #20     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (12711): #21     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (12711): #22     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
E/flutter (12711): #23     _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
E/flutter (12711): #24     _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:332:23)
E/flutter (12711): #25     _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:226:46)
E/flutter (12711): #26     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
E/flutter (12711): #27     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
E/flutter (12711): #28     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (12711): #29     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (12711): #30     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
E/flutter (12711): #31     _StreamController._add (dart:async/stream_controller.dart:658:7)
E/flutter (12711): #32     _StreamController.add (dart:async/stream_controller.dart:606:5)
E/flutter (12711): #33     _Socket._onData (dart:io-patch/socket_patch.dart:2447:41)
E/flutter (12711): #34     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
E/flutter (12711): #35     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (12711): #36     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (12711): #37     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
E/flutter (12711): #38     _StreamController._add (dart:async/stream_controller.dart:658:7)
E/flutter (12711): #39     _StreamController.add (dart:async/stream_controller.dart:606:5)
E/flutter (12711): #40     _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1116:19)
E/flutter (12711): #41     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
E/flutter (12711): #42     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter (12711): #43     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter (12711): #44     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (12711):
I/flutter (12711): [2024-05-06 10:34:20.865] Level.debug non_invite_server.dart:34 ::: Timer J expired for transaction z9hG4bKe376.21e22213.0
I/flutter (12711): [2024-05-06 10:34:20.877] Level.debug websocket_dart_impl.dart:54 ::: send:
I/flutter (12711):
I/flutter (12711): SIP/2.0 202 Accepted
I/flutter (12711): Via: SIP/2.0/WSS 199.7.173.180:443;branch=z9hG4bKe376.21e22213.0
I/flutter (12711): Via: SIP/2.0/UDP 199.7.173.100:5060;rport=5060;received=199.7.173.100;branch=z9hG4bKe376.a56c80e.0
I/flutter (12711): Via: SIP/2.0/UDP 199.7.175.102:5060;branch=z9hG4bKe376.1d5f5132.0
I/flutter (12711): Via: SIP/2.0/UDP 199.7.175.182:5060;branch=z9hG4bKe376.b1a661e.0;i=12114225
I/flutter (12711): Via: SIP/2.0/WSS 5ujl78u7dn18.invalid;rport=57306;received=106.51.51.220;branch=z9hG4bK2130537069
I/flutter (12711): To: <sip:8001@sipjs.onsip.com>;tag=k3jssj5waf
I/flutter (12711): From: "8000" <sip:8000@sipjs.onsip.com>;tag=ru8onnriu2
I/flutter (12711): Call-ID: u2568p66rxin88d758xg
I/flutter (12711): CSeq: 9042 REFER
I/flutter (12711): Supported: outbound
I/flutter (12711): Content-Length: 0
I/flutter (12711):
I/flutter (12711): [2024-05-06 10:34:20.889] Level.debug rtc_session.dart:2865 ::: runSessionTimer() | sending session refresh request
I/flutter (12711): [2024-05-06 10:34:20.894] Level.debug rtc_session.dart:2561 ::: sendUpdate()
I/flutter (12711): [2024-05-06 10:34:20.898] Level.debug rtc_session.dart:1211 ::: sendRequest()
I/flutter (12711): [2024-05-06 10:34:20.902] Level.debug transport.dart:145 ::: send()
I/flutter (12711): [2024-05-06 10:34:20.905] Level.debug websocket_interface.dart:137 ::: send()
I/flutter (12711): [2024-05-06 10:34:20.909] Level.debug websocket_dart_impl.dart:54 ::: send:
I/flutter (12711):
I/flutter (12711): NOTIFY sip:9vrwqgj2*106.51.51.220!57306_n@199.7.175.102;transport=wss;ob;nat=yes;gr SIP/2.0
I/flutter (12711): Route: <sip:199.7.173.180:443;transport=wss;r2=on;lr;ftag=ru8onnriu2>
I/flutter (12711): Route: <sip:199.7.173.180;r2=on;lr;ftag=ru8onnriu2>
I/flutter (12711): Route: <sip:199.7.173.100;lr;ftag=ru8onnriu2;did=79.26d9ec24;ns=1>
I/flutter (12711): Route: <sip:199.7.175.102;lr;ftag=ru8onnriu2;nc=1;did=79.8f6b409>
I/flutter (12711): Route: <sip:199.7.175.182;r2=on;lr;ftag=ru8onnriu2>
I/flutter (12711): Route: <sip:199.7.175.182:443;transport=wss;r2=on;lr;ftag=ru8onnriu2>
I/flutter (12711): Via: SIP/2.0/WSS o9h1rx183d6b.invalid;branch=z9hG4bK1223115687
I/flutter (12711): Max-Forwards: 69
I/flutter (12711): To: <sip:8000@sipjs.onsip.com>;tag=ru8onnriu2
I/flutter (12711): From: "8001" <sip:8001@sipjs.onsip.com>;tag=k3jssj5waf
I/flutter (12711): Call-ID: u2568p66rxin88d758xg
I/flutter (12711): CSeq: 383 NOTIFY
I/flutter (12711): Event: refer;id=9042
I/flutter (12711): Subscription-State: active;expires=300
I/flutter (12711): Content-Type: message/sipfrag;version=2.0
I/flutter (12711): Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
I/flutter (12711): Supported: outbound
I/flutter (12711): User-Agent: dart-sip-ua v0.5.3
I/flutter (12711): Conten
I/flutter (12711): [2024-05-06 10:34:20.915] Level.debug websocket_dart_impl.dart:54 ::: send:
I/flutter (12711):
I/flutter (12711): UPDATE sip:9vrwqgj2*106.51.51.220!57306_n@199.7.175.102;transport=wss;ob;nat=yes;gr SIP/2.0
I/flutter (12711): Route: <sip:199.7.173.180:443;transport=wss;r2=on;lr;ftag=ru8onnriu2>
I/flutter (12711): Route: <sip:199.7.173.180;r2=on;lr;ftag=ru8onnriu2>
I/flutter (12711): Route: <sip:199.7.173.100;lr;ftag=ru8onnriu2;did=79.26d9ec24;ns=1>
I/flutter (12711): Route: <sip:199.7.175.102;lr;ftag=ru8onnriu2;nc=1;did=79.8f6b409>
I/flutter (12711): Route: <sip:199.7.175.182;r2=on;lr;ftag=ru8onnriu2>
I/flutter (12711): Route: <sip:199.7.175.182:443;transport=wss;r2=on;lr;ftag=ru8onnriu2>
I/flutter (12711): Via: SIP/2.0/WSS o9h1rx183d6b.invalid;branch=z9hG4bK608865909
I/flutter (12711): Max-Forwards: 69
I/flutter (12711): To: <sip:8000@sipjs.onsip.com>;tag=ru8onnriu2
I/flutter (12711): From: "8001" <sip:8001@sipjs.onsip.com>;tag=k3jssj5waf
I/flutter (12711): Call-ID: u2568p66rxin88d758xg
I/flutter (12711): CSeq: 384 UPDATE
I/flutter (12711): Contact: <sip:a4ya76hr@o9h1rx183d6b.invalid;transport=wss>
I/flutter (12711): Session-Expires: 120;refresher=uac
I/flutter (12711): Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY
I/flutter (12711): Supported: timer,ice,outbound
I/flutter (12711): User-Agent: dart-sip-ua v0.5.3
I/flutter (12711): Conten
I/flutter (12711): [2024-05-06 10:34:21.675] Level.debug websocket_interface.dart:175 ::: Received WebSocket message
I/flutter (12711): [2024-05-06 10:34:21.685] Level.debug transport.dart:296 ::: received text message:
I/flutter (12711):
I/flutter (12711): SIP/2.0 200 OK
I/flutter (12711): Via: SIP/2.0/WSS o9h1rx183d6b.invalid;rport=45332;received=106.51.51.220;branch=z9hG4bK608865909
I/flutter (12711): To: <sip:8000@sipjs.onsip.com>;tag=ru8onnriu2
I/flutter (12711): From: "8001" <sip:8001@sipjs.onsip.com>;tag=k3jssj5waf
I/flutter (12711): Call-ID: u2568p66rxin88d758xg
I/flutter (12711): CSeq: 384 UPDATE
I/flutter (12711): Contact: <sip:9vrwqgj2*106.51.51.220!57306_n@199.7.175.102;transport=wss;ob;gr>
I/flutter (12711): Session-Expires: 120;refresher=uac
I/flutter (12711): Supported: timer,replaces,outbound
I/flutter (12711): Content-Length: 0
I/flutter (12711): P-NS: 1
I/flutter (12711): 
I/flutter (12711):
I/flutter (12711): [2024-05-06 10:34:21.739] Level.debug websocket_interface.dart:175 ::: Received WebSocket message
I/flutter (12711): [2024-05-06 10:34:21.742] Level.debug transport.dart:296 ::: received text message:
I/flutter (12711):
I/flutter (12711): SIP/2.0 500 DartSIP Internal Error
I/flutter (12711): Via: SIP/2.0/WSS o9h1rx183d6b.invalid;rport=45332;received=106.51.51.220;branch=z9hG4bK1223115687
I/flutter (12711): To: <sip:8000@sipjs.onsip.com>;tag=ru8onnriu2
I/flutter (12711): From: "8001" <sip:8001@sipjs.onsip.com>;tag=k3jssj5waf
I/flutter (12711): Call-ID: u2568p66rxin88d758xg
I/flutter (12711): CSeq: 383 NOTIFY
I/flutter (12711): Supported: outbound
I/flutter (12711): Content-Length: 0
I/flutter (12711): P-NS: 1
I/flutter (12711): 
I/flutter (12711):

To Reproduce
Steps to reproduce the behavior:

  1. Connect to JsSIP public server like below:
await _sipuaHelper.start(
      UaSettings()
        ..webSocketUrl = "wss://edge.sip.onsip.com"
        ..webSocketSettings.transport_scheme = "WSS"
        ..webSocketSettings.extraHeaders = <String, dynamic>{
          "Origin": " https://tryit.jssip.net",
        }
        ..displayName = dest
        ..password = dest
        ..authorizationUser = dest
        ..uri = "sip:$dest@sipjs.onsip.com",
    );
  1. Make call a from one device to other
  2. Once call get connected, try call.refer()
  3. you will get the above error

Expected behavior
Once fun call.refer() is called, it should processes the request and notifies the involved parties, ultimately establishing a new call leg to the new destination.

System Infomation()
Flutter SDK Version: 3.19.6
Target OS and Version: 23.10