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

HttpException: Connection closed while receiving data #1900

Closed
Oleksii-Milkov opened this issue Jul 21, 2023 · 3 comments
Closed

HttpException: Connection closed while receiving data #1900

Oleksii-Milkov opened this issue Jul 21, 2023 · 3 comments
Labels
i: wontfix This will not be worked on

Comments

@Oleksii-Milkov
Copy link

Oleksii-Milkov commented Jul 21, 2023

Package

dio

Version

5.1.2

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.10.4, on Ubuntu 22.04.2 LTS 5.19.0-46-generic, locale en_US.UTF-8)
• Flutter version 3.10.4 on channel stable at /home/oleksii/fvm/versions/3.10.4
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 682aa387cf (7 weeks ago), 2023-06-05 18:04:56 -0500
• Engine revision 2a3401c9bb
• Dart version 3.0.3
• DevTools version 2.23.1

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /home/oleksii/Android/Sdk
✗ cmdline-tools component is missing
Run path/to/sdkmanager --install "cmdline-tools;latest"
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.

[✓] Chrome - develop for the web
• Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
• Ubuntu clang version 14.0.0-1ubuntu1
• cmake version 3.22.1
• ninja version 1.10.1
• pkg-config version 0.29.2

[!] Android Studio (version 2023.1)
• Android Studio at /home/oleksii/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-1/231.7864.76.2311.10114981
• Flutter plugin version 73.1.1
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.

[✓] Android Studio (version 2022.1)
• Android Studio at /home/oleksii/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386
• Flutter plugin version 72.1.2
• Dart plugin version 221.6096
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] Android Studio (version 2022.2)
• Android Studio at /home/oleksii/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.9971841
• Flutter plugin version 74.0.2
• Dart plugin version 222.4582
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code
• VS Code at /snap/code/current
• Flutter extension version 3.64.0

[✓] Connected device (3 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator)
• Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.2 LTS 5.19.0-46-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.92

[✓] Network resources
• All expected network resources are available.

Dart Version

3.0.3

Steps to Reproduce

  1. Send request with ResponseType.stream
final response = await _client.get(
    _someEndpoint,
    options: Options(
    headers: {
        "Content-Type": "application/octet-stream",
        "Cache-Control": "no-cache",
        "Connection": "Keep-Alive",
    },
    responseType: ResponseType.stream,
    ),
);
return response;
  1. Receive response, and listen to stream
final someStream = await createStream();
someStream?.data?.stream
    .transform(someUnit8Transformer)
    .transform(const Utf8Decoder())
    .listen((event) async {
        // Do something with data
});
  1. Add onError() callback on StreamSubscription (HttpException received only inside onError(), not try-catch)
try {
    final someStream = await createStream();
    someStream?.data?.stream
        .transform(someUnit8Transformer)
        .transform(const Utf8Decoder())
        .listen((event) async {
            // Do something with data
    }).catchError((err) {
        /// After 20 seconds of idle receive _HttpException: Connection closed while receiving data_ here
        print(err);
    });
} catch (err) {
    /// There are no errors
}
  1. Wait 20 seconds of stream idle. If data received more often than in 20 seconds- everything works fine
  2. Receive HttpException: Connection closed while receiving data

Expected Result

Correct work of stream and receiving all events

Actual Result

After 20 seconds of stream idle, onError() callback throw HttpException: Connection closed while receiving data. If data received more often than in 20 seconds- everything works fine.
Also i can said that i tried to configure dio.options timeouts, but there are no effect.

@Oleksii-Milkov Oleksii-Milkov added h: need triage This issue needs to be categorized s: bug Something isn't working labels Jul 21, 2023
@Oleksii-Milkov
Copy link
Author

Issue was on the server side.

@AlexV525 AlexV525 added i: wontfix This will not be worked on and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Jul 29, 2023
@melyama
Copy link

melyama commented Feb 25, 2024

Issue was on the server side.

Hi,
Could you be more specific. What was the problem on the server side if you can remember? I'm facing the same exception. Server seems to respond from logs on its side, but client says the connection was closed before response was received.

@rockeypandit
Copy link

#metoo facing same issue from past some days. Can you also mention what is the backend you are using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i: wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants