-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
Network calls don't show in Charles Proxy Debugger #20376
Comments
It's also not working on a physical device... :( |
Same here, both on physical device nor simulator/ emulator no way to get them to show up in charlesproxy while badly needed |
We're still trying to figure out how to best default this but for now, could you guys try using the If you want to override how HttpClients are created, use https://api.dartlang.org/stable/2.1.0/dart-io/HttpOverrides-class.html |
This should probably be addressed upstream in dart:io. /cc @zanderso From conversation with him, our best bet seems to be to target updating https://github.com/dart-lang/sdk/blob/master/runtime/bin/platform_macos.cc#L203 with information from https://developer.apple.com/documentation/cfnetwork/1426754-cfnetworkcopysystemproxysettings?language=objc. |
Does this work as-is on Android? If not we'd probably want a similar strategy there. |
Nope. Stackoverflow says https://stackoverflow.com/a/13616054/. Can we access Java APIs from the dart:io code? |
There is currently not a good way to make JNI calls from the |
I'm using dio to set proxy. |
I am using dio too. iOS physical device can get both http and https api payload, but android physical device can only get http api payload. And I have install certification for device and charles can get https api for native app. but can't work for flutter app. Did you encounter this problem? |
I find a way for android devices. But I am not sure any side effect bool isProxyChecked = true // a variable for debug
String proxy = '192.168.2.2:8888' // ip:port
final dio = Dio()
..onHttpClientCreate = (client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) {
return isProxyChecked && Platform.isAndroid;
};
client.findProxy = (url) {
return isProxyChecked ? 'PROXY $proxy' : 'DIRECT';
};
} |
It works for me, thanks |
I was able to get this working using https://stackoverflow.com/questions/50949938/flutter-app-ios-simulator-set-transparent-proxy localhost can be the ip address for your computer like 192.168.1.77 HttpClient client = HttpClient();
client.findProxy = (uri) {
return "PROXY localhost:3128;";
}; A more full implementation: static HttpClient getHttpClient() {
HttpClient client = new HttpClient()
..findProxy = (uri) {
return "PROXY 192.168.1.199:8888;";
}
..badCertificateCallback =
((X509Certificate cert, String host, int port) => true);
return client;
} |
@dazza5000 and you can use HttpOverrides to make Flutter use the same HttpClient. See https://stackoverflow.com/questions/54321077/best-way-to-set-default-header-for-all-request-in-flutter-http-request for an example |
@nashfive |
@dazza5000 TY! |
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
// config the http client
client.findProxy = (uri) {
//proxy all request to localhost:8888
return "PROXY localhost:8888";
};
// you can also create a new HttpClient to dio
// return new HttpClient();
}; |
Android Simulator
iPhone Simulator
physical device (Android/iPhone)
This can also be used for simulators (skip adding proxy server settings in system settings). |
For anyone else who ends up here, I compiled all of the solutions above (for the most part) into a blog post along with some other options to debug network requests in Flutter: |
I suspect dart-lang/sdk#41376 will solve this problem on iOS. Using posix sockets is probably not respecting the OS's proxy settings like it is for VPN settings. |
@saurabhrayakwar Can you see a body of requests? |
If you are using android studio emulator use 10.0.2.2 and for genymotion 10.0.3.2 if localhost is not working. |
var httpClient = HttpClient(); Doesn't work for me. Can not proxy |
Will this ever be solved? It's not only affecting Charles proxy. This problem affects the capability of Flutter created APPS to run using local capabilities (using proxies) on platforms like Browserstack or similar... What in the end will limit the usage of Flutter for production apps... As I see it, this is an understandable limitation. |
@JordiGiros Did you see the workaround posted here: dart-lang/sdk#41376 (comment) At this point I think making a plugin is your best bet, doing what the linked workaround is doing or wrapping Apple's http APIs. The Dart team at this point has demonstrated this is not a priority for them. The workaround is easy to implement, you are better off doing that. Maybe the Flutter team can make an official plugin. I'll shop the idea around. |
Does anyone know the reason behind. I would like to understand the technical perspective |
The proposal from @gaaclarke was discarded after trying it some months ago due to the fact that the library being used returns "null" when asking for the proxy info using it in BrowserStack. |
Hello @markusaksli-nc |
I don't have any extra insight or news, #20376 (comment) is still the best answer probably. FYI Not sure what the status is on what was mentioned but I'm not the one to ask for that either. This is probably still your best bet #20376 (comment) |
I'm facing this too. Trying to debug my own App but with Charles Proxy. I can see even Instagram requests, but not my app requests. |
There are other solutions suggested for using Charles Proxy i.e. setting Another option is
late Client client;
if (Platform.isIOS) {
final config = URLSessionConfiguration.ephemeralSessionConfiguration()
# Do whatever configuration you want.
..allowsCellularAccess = false
..allowsConstrainedNetworkAccess = false
..allowsExpensiveNetworkAccess = false;
client = CupertinoClient.fromSessionConfiguration(config);
} else {
client = IOClient(); // Uses an HTTP client based on dart:io
}
final response = await client.get(Uri.https(
'www.googleapis.com',
'/books/v1/volumes',
{'q': 'HTTP', 'maxResults': '40', 'printType': 'books'})); I would really appreciate it if you can try Comments or bugs in the |
I ran into the same issue but then one of my colleagues suggested this package: https://pub.dev/packages/http_proxy. That said, It would be nice to work out-of-the-box. |
@SEGVeenstra |
cupertino_http has been available for over a year now and has transparent support for iOS proxies. We are recommending that people use it on iOS. |
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 |
Steps to Reproduce
My HTTPS calls are actually fired and I get HTTP responses in my code and I can see the calls in my server logs.
Flutter (or Dart ?) doesn't seem to use the system proxy so I can't see any of my network calls' payloads.
I tried to launch the app in debug mode with
http_proxy
andhttps_proxy
in the command line but this doesn't change anything :The text was updated successfully, but these errors were encountered: