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 prot
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.
I fixed the issue by setting request.persistentConnection = false; (default is true)
Writing this in case someone has the same problem...
I figured out how to limit the connections on the underlying HttpClient of NetworkImage!
I globally overrode the HttpClient: (ref: Override HttpClient globally)
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext context) {
return super.createHttpClient(context)
..maxConnectionsPerHost = 5;
}
}
void main() {
HttpOverrides.global = MyHttpOverrides();
runApp(MyApp());
}
Ref : Connection closed...
I found the solution/work around. For me, it worked on physical device but not on emulator. The simple fix is to use your an emulator of x86 environment rather than x86_64 emulator.
I got the same error when I using Flutter with http package.
import 'package:http/http.dart' as http;
...
http.Response response = http.get('url')
This was fine. But when I went to get the response.statusCode
, it Error connecting
error.
I found that I'm using SSR/v2Ray on my pc. I fix it by setting the proxy on Android Emulator extended controls panel.
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.