Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix HttpException: Connection closed before full header was received

I have recently upgraded my flutter version in my app. But when I want to debug the application, it shows me the following error.

Error connecting to the service protocol: HttpException: Connection closed before full header was received, URI = http://127.0.0.1:50795/ws

Is there anyone facing the same issue after upgrading the flutter version? If is there any workaround, please share.

like image 330
Juthi Sarker Aka Avatar asked Apr 27 '19 10:04

Juthi Sarker Aka


People also ask

How to handle connection closed before full header in imageerrorbuilder?

My solution to fix this issue is we can use FadeInImage to know when is the request image got the error Connection closed before full header was received, URI = we can handle it on imageErrorBuilder method.

When does the secure connection end?

The secure connection ends before the content of http response doesn't come back. Http Parser will report the exception "connection closed before full header was received". I did a comparison between the dart and curl.

Why is my widget not responding to HTTP request?

It may be because the widget is reused in the widget tree and thus interrupts the HTTP request. You could then use a key in your FutureBuilder or Image widget. child: FutureBuilder<File> ( key: ValueKey (imageUrl), // or use UniqueKey () ... Show activity on this post.


Video Answer


4 Answers

Right now this issue is opened on github https://github.com/flutter/flutter/issues/32587

Temporarily you can solve this issue by switching to physical device instead of emulator How to test android apps in a real device with Android Studio?

Decision found on github (link upward)

I've got a temporary work around, which I can use for now. The exception above is thrown when I run the emulator as a Pixel 3 Android 9.+ Target (Q API). I made up a second emulated device, a Pixel 2 Android 9.0 Target (28 API), and this target works fine.

I'm also noticing that the Pixel 2 target takes up 8.5GB on Disk, while the Pixel 3 target only takes up 1.4GB. It makes me wonder if the Pixel 3 target is missing some important things.

like image 84
awaik Avatar answered Oct 22 '22 23:10

awaik


The issue is mainly with Android Q.

You can downgrade your android version from Android Q to Android Pie.

which eventually leads to resolve the issue.

like image 17
Vicky Salunkhe Avatar answered Oct 23 '22 00:10

Vicky Salunkhe


No solution unless the Flutter guys fix it.

I'm having it on one machine (Mac OS Mojave) even when connecting physical iOS devices. Of course it happens too with emulated Android devices (no matter which one).

I've also having this problem in a different computer (MacOS Mojave too) with a physical Android device (with a very old Android version: 5.1).

flutter clean does not fix it at all in my case(s).

like image 15
nbloqs Avatar answered Oct 23 '22 00:10

nbloqs


First turning off your WiFi/Bluetooth.

And run below command:

flutter clean

And then quitting or restarting your emulator.

like image 11
Payam Khaninejad Avatar answered Oct 23 '22 00:10

Payam Khaninejad