Websocket connection is closed abruptly in asterisk using Web RTC connection when my flutter app terminated (User swipe to close app) Flutter version Flutter 3.24.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision 80c2e84975 (3 months ago) • 2024-07-30 23:06:49 +0700 Engine • revision b8800d88be Tools • Dart 3.5.0 • DevTools 2.37.2 Flutter library used sip_ua: https://pub.dev/packages/sip_ua Asterisk version Asterisk 20.4.0 I tried using flutter background service to open the connection as soon as the connection is closed: @pragma('vm:entry-point') static void onStart(ServiceInstance service) async { print("call background serivce is starting"); SipUAListenerBackground newListener = SipUAListenerBackground(); SipHelperManager().getHelper().addSipUaHelperListener(newListener); } and for my SipUAListenerBackground: class SipUAListenerBackground implements SipUaHelperListener { @override void transportStateChanged(TransportState state) { // If state is closed // ... UaSettings settings = UaSettings() ..webSocketUrl = savedLoginInfo['websocketUrl'] ..uri = 'sip:${savedLoginInfo['username']}@${savedLoginInfo['server']}' ..authorizationUser = savedLoginInfo['authorizationUser'] ..password = savedLoginInfo['password'] ..displayName = savedLoginInfo['displayName'] ..userAgent = 'Flutter SIP Client' ..dtmfMode = DtmfMode.RFC2833; await _sipHelper!.start(settings); } } Continue reading...