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

Connection closed while receiving data #22951

Closed
Mythar opened this issue Oct 11, 2018 · 28 comments
Closed

Connection closed while receiving data #22951

Mythar opened this issue Oct 11, 2018 · 28 comments
Labels
dependency: dart Dart team may need to help us engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list

Comments

@Mythar
Copy link

Mythar commented Oct 11, 2018

Im getting this a lot when calling my backend Django REST api (localhost).

What i have found on the web is that, this is a problem when using an emulator, and everything works just fine on a "real" device.

Its like the http call (POST, PUT etc.) does not give the host enough time to respond.
I monitor the server responses and the server dose respond correctly but connection gets cut off.

Its very annoying when working in a development environment, i was wondering if any has a solution to this?

@zoechi zoechi added engine flutter/engine repository. See also e: labels. dependency: dart Dart team may need to help us labels Oct 11, 2018
@zoechi zoechi added this to the Goals milestone Oct 11, 2018
@sanmaozhao
Copy link

Same issue here.
Real device work fine, bug Andriod emulator fail.

@zoechi
Copy link
Contributor

zoechi commented Nov 21, 2018

Please add the output of flutter doctor -v.

@sanmaozhao
Copy link

sanmaozhao commented Nov 21, 2018

flutter doctor -v
[√] Flutter (Channel beta, v0.11.8, on Microsoft Windows [Version 10.0.17134.407], locale zh-CN)
    • Flutter version 0.11.8 at D:\flutter
    • Framework revision f5b02e3c05 (16 hours ago), 2018-11-20 07:49:29 -0800
    • Engine revision 1baf081343
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[√] Android toolchain - develop for Android devices (Android SDK 26.0.2)
    • Android SDK at D:\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-27, build-tools 26.0.2
    • ANDROID_HOME = D:\Android\sdk
    • Java binary at: D:\Android\Android Studio 2\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[√] Android Studio (version 3.2)
    • Android Studio at D:\Android\Android Studio 2
    • Flutter plugin version 30.0.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[!] VS Code, 32-bit edition (version 1.11.2)
    • VS Code at C:\Program Files (x86)\Microsoft VS Code
    • Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

@davewang
Copy link

Same issue here.

@aleaforny
Copy link

I'm experiencing the same issue while using a Django environment as a backend.
I'm trying to retrieve an image from my Django website (simple GET request), I tried several widgets (NetworkImage, AdvancedNetworkImage, CachedNetworkImage), but I got the exact same error everytime. Nothing wrong on server-side, it returns code 200 OK.

It is important to note that my Django server was located in the same subnet as the emulated device (development environment, in the same private network). This issue does NOT occur while getting images from the "Internet". I finally found a workaround by hosting the images at a different location outside of my network (remote website storage).

Maybe it is also important to note that (in my case), this issue had nothing to do with the image sizes (I got the issue on images from 4 Ko to +10 Mo, but no issues at all when fetching Internet images).

Hope this can be fixed very soon, it will help greatly working in a development environment :)

@Mythar
Copy link
Author

Mythar commented Feb 15, 2019

My workaround was to use an old PC as server on my private network.
Issue occurs when server and development are on the same IP.

@The-Redhat
Copy link
Contributor

The-Redhat commented Mar 14, 2019

I got the same issue with a real iPone 6s.

@lifetin
Copy link

lifetin commented Mar 25, 2019

我是安卓的模拟器 也出现同样的问题
换到genymotion正常.

@zhangzhenxi
Copy link

I fixed this by remove proxy config for my Android emulator in my case.

https://www.dartlang.org/tools/pub/troubleshoot

@aleaforny
Copy link

I fixed this by remove proxy config for my Android emulator in my case.

https://www.dartlang.org/tools/pub/troubleshoot

How did you do, exactly? The link you've provided helps to set up a proxy on the machine, not to remove proxy config for the Android emulator, AFAIK.

The issue is still occuring

Thanks

@zhangzhenxi
Copy link

remove proxy config for the Android emulator

image

@aleaforny
Copy link

Thanks @zhangzhenxi !

I guess it did the trick, the issue does not occur every time now.

I assume this is a workaround though ; do we have an ETA on a possible fix release?

Thanks again for your help 👍

@dayofbrian
Copy link

I'm also experiencing this issue. Turning off the proxy only makes the issue become random (does not fail every time). My REST API is on another server on the local network. This issue makes it impossible to do any development work.

@aleaforny
Copy link

@dayofbrian it's been several months now that I've not faced this issue anymore.

Perhaps it can help you; what version of Android Studio do you use? Same question for the AVD?
On my hand, my AVD is a Pixel 2 API 28 x86, and Android Studio 3.5.3
And I use cached_network_image version 2.0.0-rc.

Turning off the proxy definitely did the trick.

Hope this can help.

@dayofbrian
Copy link

I've basically started using my Samsung device to do all development.

Android Studio 3.5.3 looks like 3.6.2 is available now
Also using a Pixel 2 API 28 for the virtual device
No idea how to find the AVD version, I hunted all over for it, but it was part of AS 3.5.3
No idea what the cached_network_image is either.

@raminri
Copy link

raminri commented Apr 10, 2020

Also getting this issue with both images & other large downloads. This is making it very difficult to do any local development.

Disabling proxy hasn't fixed the issue for me.

@uzumaki258
Copy link

I faced the problem with load multi-image files, but sometimes, maybe problem at my server

@marhyno
Copy link

marhyno commented May 6, 2020

any update on this ? facing same issue on any emulator, but real phone works fine

@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
@Hixie Hixie removed this from the None. milestone Aug 17, 2020
@whatamelon
Copy link

Like above issues, I'm facing this issue with load multiple images too.
In my guess, api server sent to me well, but in my response header is closed before whole images coming.
So, I just want to know. Why header is closing while response is coming.

@darshankawar
Copy link
Member

@Mythar
Is still a valid issue using latest Flutter version ?
Thanks.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 2, 2020
@adgrover
Copy link

adgrover commented Oct 2, 2020

I had been encountering the same issues. My use case was that i was running a flask application on the localhost and accessing the REST endpoints through the URL. The workaround I got was exposing my localhost through a tunneling service.

You can consider using ngrok. Of course, your data will be routed through a third-party service but yeah

@pedromassangocode pedromassangocode removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 23, 2020
@pedromassangocode
Copy link

pedromassangocode commented Oct 23, 2020

Without additional information, we are unfortunately not sure how to resolve this issue.
We are therefore reluctantly going to close this bug for now.
Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.

Could everyone who still has this problem please file a new issue with the exact description of what happens, logs, and the output of flutter doctor -v.
All system setups can be slightly different, so it's always better to open new issues and reference related issues.

@godilite
Copy link

godilite commented Nov 5, 2020

This issue still occur

@altafkhan8719
Copy link

I am also facing the same issue while downloading a large file,
I am using dio: ^3.0.10
HttpException: Connection closed while receiving data,

@AwsmAsim
Copy link

AwsmAsim commented Dec 7, 2020

I had been encountering the same issues. My use case was that i was running a flask application on the localhost and accessing the REST endpoints through the URL. The workaround I got was exposing my localhost through a tunneling service.

You can consider using ngrok. Of course, your data will be routed through a third-party service but yeah

For Flask backend:
Add from werkzeug.serving import WSGIRequestHandler and
add WSGIRequestHandler.protocol_version = "HTTP/1.1" before: app.run(...)

Also don't forget to remove proxy config for the Android emulator

This is what solved the problem in my case.

@alboto
Copy link

alboto commented May 25, 2021

I had been encountering the same issues. My use case was that i was running a flask application on the localhost and accessing the REST endpoints through the URL. The workaround I got was exposing my localhost through a tunneling service.
You can consider using ngrok. Of course, your data will be routed through a third-party service but yeah

For Flask backend:
Add from werkzeug.serving import WSGIRequestHandler and
add WSGIRequestHandler.protocol_version = "HTTP/1.1" before: app.run(...)

Also don't forget to remove proxy config for the Android emulator

This is what solved the problem in my case.

It works ! Thanks a lot!

@sgsm74
Copy link

sgsm74 commented Jul 29, 2021

same issue for me
backend is laravel

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependency: dart Dart team may need to help us engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list
Projects
None yet
Development

No branches or pull requests