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

Operation is unstable when disconnecting and reconnecting Wi-Fi during a call, or when disconnecting Wi-Fi and connecting to mobile (4G/5G) #446

Open
ryotasakurada opened this issue Jun 23, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@ryotasakurada
Copy link

ryotasakurada commented Jun 23, 2024

Describe the bug
I am using dart-sip-ua to make calls via Asterisk.
Because the behavior of the mobile device is unstable when changing networks, I am reporting this.

background:
The device is connected to Asterisk using a client-server method, not a P2P connection.
I am using ICE to send the results to Asterisk to make WebRTC calls.

To Reproduce
Steps to reproduce the behavior:
The behavior is unstable on both iOS and Android, but it is particularly noticeable on Android, so I will give an example of an Android device.

  1. Start a call between two devices (device <-> Asterisk <-> device)
  2. Disconnect the Android device's Wi-Fi (It is assumed that there is no 4G connection)
    2-1. The call is disconnected at this point
  3. Reconnect the Android device's Wi-Fi. Of course, the call has already ended, so it cannot be resumed.

Expected behavior
If you are making a SIP call, the call should resume when you reconnect to Wi-Fi (confirmed with Zoiper SIP Client)

System Infomation()
Flutter SDK Version: 3.22.2
Target OS and Version: Android 10,11,12
sip-ua-dart version: 0.6.0

@ryotasakurada ryotasakurada added the bug Something isn't working label Jun 23, 2024
@viniciusoliverrs
Copy link

I have the same problem. Any solution?

@reduxdj
Copy link

reduxdj commented Oct 15, 2024

The solution is rather complicated, and requires a change in _iceRestart and the transport, first comment out the terminate call in there, set _iceRestarts true in the options under mandatory

Overload the transport library, ours looks like this, we use connectivity plus and a dart:io to check when we have wifi/mobile and can make a successful lookup of google's address.

when you have a successful internet restored, call renegoation({ useUpdate: true}, this forces a reconnection to your webrtc connection, so expose this function from transport.dart to your session...

Somethiing like this:

  bool send(dynamic data) {
    // logger.d('send()');

    if (!isConnected()) {
      logger.e('unable to send message, transport is not connected. Current state is $status', stackTrace: StackTraceNJ());
      return false;
    }
    bool isOutgoing = data is OutgoingRequest;

    String message = data.toString();
    //logger.d('sending message:\n\n$message\n');
    if (isOutgoing) {
      OutgoingRequest outgoing = data;
      if (outgoing.method == SipMethod.UPDATE) {
        _reconnect(() {
          socket.send(message);
          disableDisconnectionEvent = false;
        });
        return true;
      }
    }

    return socket.send(message);
  }

@aberutti-convorelay
Copy link

aberutti-convorelay commented Oct 21, 2024

Hi @reduxdj. Could you elaborate a little bit more on your response? I'm having the same issue but with desktop flutter. When turning off/on the WiFi at a certain timing RTCIceConnectionStateDisconnected is triggered and _iceRestart() is being called but the re-INVITE is not reaching the server although the re-registering was successful and they are hitting the request timeout, I've implemented a retry policy but no luck so far, invites are never reaching the sip server. I really appreciate any help you can provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants