# How to execute disconnect with a false argument in Flutter SDK

**URL:** <https://community.sendbird.com/t/how-to-execute-disconnect-with-a-false-argument-in-flutter-sdk/10571>\
**Category:** Flutter\
**Tags:** chatsdk\
**Created:** [January 28, 2025, 5:01am UTC](https://community.sendbird.com/t/how-to-execute-disconnect-with-a-false-argument-in-flutter-sdk/10571 "2025-01-28T05:01:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![y.kitaike716](https://avatars.discourse-cdn.com/v4/letter/y/ecccb3/32.png) [@y.kitaike716](https://community.sendbird.com/u/y.kitaike716)\
**Post date:** [January 28, 2025, 5:01am UTC](https://community.sendbird.com/t/how-to-execute-disconnect-with-a-false-argument-in-flutter-sdk/10571/1 "2025-01-28T05:01:42Z")

</div>

**[Problem/Question]**  
To control the number of simultaneous connections, we would like to execute the disconnect() method while the chat screen is not open.

However, in the current SDK implementation, the disconnect() method can only be used as a “strong” disconnect with a true logout argument.

> <https://github.com/sendbird/sendbird-chat-sdk-flutter/blob/master/lib/src/internal/main/connection_state/disconnected_state.dart#L39-L43>

```dart
  @override
  Future<void> disconnect({required bool logout}) async {
    sbLog.i(StackTrace.current);
    await chat.connectionManager.doDisconnect(clear: logout, logout: logout);
  }

```

The method that is executed when the app enters the background state is a “weak” disconnect() with a logout argument of false, allowing the use of the reconnect() method.

Is there any reason why “weak” disconnect() cannot be used when the app is in the foreground state? Are there any plans for modification?

Translated with [DeepL.com](http://DeepL.com) (free version)

* * *

// If problem, please fill out the below. If question, please delete.  
**[SDK Version]**

# sendbird\_chat\_sdk 4.2.30

**[Reproduction Steps]**  
// Please provide reproduction steps and, if possible, code snippets.

**[Frequency]**  
// How frequently is this issue occurring?

**[Current impact]**  
// How is this currently impacting your implementation?

---

<div class="post-metadata">

**Author:** ![sardorbek.numonov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/sardorbek.numonov/32/697_2.png) [@sardorbek.numonov](https://community.sendbird.com/u/sardorbek.numonov)\
**Post date:** [February 10, 2025, 1:15am UTC](https://community.sendbird.com/t/how-to-execute-disconnect-with-a-false-argument-in-flutter-sdk/10571/2 "2025-02-10T01:15:38Z")

</div>

Hi @y.kitaike716.

Disconnecting with `logout` set to `false` is intended for use with Local Caching.

When a user disconnects with `logout` set to `true`, the Sendbird SDK clears messages and channels stored in the local database while terminating the WebSocket connection. However, if `logout` is set to `false`, the SDK only terminates the WebSocket connection while preserving the locally stored messages and channels.

As a result, the Sendbird SDK performs a “weak” disconnect (i.e., `logout = false`) when the app transitions to the background. However, the SDK has its own reconnection mechanism. There is a distinction between a user manually calling `disconnect()` with `logout` set to `false` and the SDK automatically doing so when the app moves to the background. If a user manually calls `disconnect()` with `logout` set to `false`, the SDK will not attempt to reconnect until `Sendbird.connect()` is explicitly invoked.

Moreover, if you are not using Local Caching, the `logout` parameter (whether `true` or `false`) has no effect on the disconnect behavior.
