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

App ignores proxy settings #26359

Open
christian-muertz opened this issue Jan 10, 2019 · 38 comments
Open

App ignores proxy settings #26359

christian-muertz opened this issue Jan 10, 2019 · 38 comments
Labels
c: new feature Nothing broken; request for a new capability dependency: dart Dart team may need to help us engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list team-engine Owned by Engine team triaged-engine Triaged by Engine team

Comments

@christian-muertz
Copy link
Contributor

We need a way to access the system configured proxy.
In networks where a proxy is required to enter the internet, this is critical.

Currently, I'm not able to use any flutter app in such networks where a proxy is configured in the system settings.

@zoechi

This comment has been minimized.

@zoechi zoechi added c: new feature Nothing broken; request for a new capability waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine repository. See also e: labels. dependency: dart Dart team may need to help us labels Jan 10, 2019
@christian-muertz

This comment has been minimized.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 10, 2019
@zoechi

This comment has been minimized.

@christian-muertz
Copy link
Contributor Author

I'm not that familiar with the topic but try using a flutter app that accesses the internet inside a network that requires the traffic to go to a proxy to enter the internet. For example in my school all the network traffic requires going through the schools proxy for logging etc. All apps manage to access the internet except flutter apps.

@christian-muertz
Copy link
Contributor Author

Currently waiting for this issue to be resolved before releasing the app in the stores.

@zoechi zoechi added this to the Goals milestone Jan 11, 2019
@zoechi

This comment has been minimized.

@zoechi

This comment has been minimized.

@christian-muertz
Copy link
Contributor Author

christian-muertz commented Jan 11, 2019

It does not matter whether the proxy is detected automatically or is set manually in the system settings. The HTTP client just ignores the system-wide set proxy.

@zoechi zoechi changed the title Automatic Proxy Detection App ignores proxy settings Jan 11, 2019
@zoechi
Copy link
Contributor

zoechi commented Jan 11, 2019

Sorry, I misinterpreted the request.

@christian-muertz
Copy link
Contributor Author

christian-muertz commented Jan 11, 2019

Sorry, title was misleading.

@christian-muertz
Copy link
Contributor Author

Might be related to #20376.

@zoechi
Copy link
Contributor

zoechi commented Jan 20, 2019

@christian-muertz
Copy link
Contributor Author

christian-muertz commented Jan 20, 2019

The issue is not to get the http client use the specified proxy. The issue is finding out the global proxy settings.

@zoechi
Copy link
Contributor

zoechi commented Jan 23, 2019

Might be a duplicate of #20376

See also about how to set a custom HttpClient that finds and applies proxy settings for every request:
#20376 (comment)
#19588 (comment)
https://stackoverflow.com/questions/54321077/best-way-to-set-default-header-for-all-request-in-flutter-http-request

@christian-muertz
Copy link
Contributor Author

#20376 is caused by the same issue but is not a direct dupliacte.

@maks
Copy link

maks commented Apr 5, 2019

@zoechi Basically what this issue is asking for is not having to use a plugin as described in: https://stackoverflow.com/a/50092642/85472

I guess the question is is it up to Http client to automatically use the host-system (android, ios, etc) configured proxy settings or is it up to the app developer to get that setting somehow and then use:

final proxyUrl = getHttpProxySomehowFromEmbeddingSystem();
class ProxiedHttpOverrides extends HttpOverrides {
  @override
  HttpClient createHttpClient(SecurityContext context) {
    return super.createHttpClient(context)
      ..findProxy = (uri) {
        return "PROXY $proxyUrl;";
      }
  }
}

@tghosth
Copy link

tghosth commented Jul 22, 2019

Hi @christian-muertz, did you get anywhere with this?

@duongtruong12
Copy link

Hi @christian-muertz , did you fix the problem, can you share experience please?

@SVyatoslavG
Copy link

I am having the same issue. Any news on this topic?

@REKURDennis
Copy link

Hi,

is there any plan to fix this issue in the future? Sadly for business apps this is a real problem, since many companies use some proxy configuration. And I fully agree with the previous comments, that using the system proxy should be the default behaviour.

@rajasekar-mu
Copy link

We also facing similar issue at corporate network on using android mobile app. tried with findProxy method, but did not get actual proxy information.
https://api.flutter.dev/flutter/dart-io/HttpClient/findProxy.html

@engine-flutter-autoroll, @jonahwilliams - many users facing CORP network issue, please fix as soon as possible.

@maks
Copy link

maks commented Aug 9, 2021

@rajasekar-mu you need to read the actually documentation you linked to, findProxy:

Sets the function used to resolve the proxy server to be used

you need to then provide a function that provides the proxy server to be used.

@rajasekar-mu
Copy link

rajasekar-mu commented Aug 10, 2021

@maks i provided the function on initial loading. But its return localhost for proxy value, while debugging on corporate network. At the same time perfectly working internet users to return DIRECT. are you know any other way to solve this problem on fetching proxy information form corp network?

@jerryzhoujw
Copy link

Here is a plugin which is able to get the system's proxy settings on android and ios:

https://github.com/kaivean/system_proxy

This one save my life.

@sebastianlyserena
Copy link

Has anyone solved the proxy for android 7 and up?

@ShokhrukhDeveloper
Copy link

HI

@devmgs
Copy link

devmgs commented Oct 25, 2022

I have successfully used the following method which works on android and ios.

https://pub.dev/packages/http_proxy

code is as follows

import 'package:http_proxy/http_proxy.dart';



void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  if (GetPlatform.isAndroid || GetPlatform.isIOS) {
    HttpProxy proxy = await HttpProxy.createHttpProxy();
    HttpOverrides.global = proxy;
  }
.........

@komaxx
Copy link

komaxx commented Oct 25, 2022

@devmgs
I think you might want to re-consider your solution!

http_proxy contains the following lines:

var client = super.createHttpClient(context);
    client.badCertificateCallback =
            (X509Certificate cert, String host, int port) {
      return true;
    };
    return client;

This effectively turns off all certificate checking. With it, your app is wide open to a wide range of attacks :(

Granted, I don't have a better solution right now but I think we should not be happy with this workaround..

@phamquoctrongnta
Copy link

phamquoctrongnta commented Feb 6, 2023

Here is a plugin which is able to get the system's proxy settings on android and ios:
https://github.com/kaivean/system_proxy

This one save my life.

Does this working when use proxy with authentication (username & password)?

@hariprasad47
Copy link

I have successfully used the following method which works on android and ios.

https://pub.dev/packages/http_proxy

code is as follows

import 'package:http_proxy/http_proxy.dart';



void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  if (GetPlatform.isAndroid || GetPlatform.isIOS) {
    HttpProxy proxy = await HttpProxy.createHttpProxy();
    HttpOverrides.global = proxy;
  }
.........

This works on Android but I am still unable to make it work on iOS device does anyone have a solution to make flutter proxy aware for iOS devices.

@sherry0429
Copy link

I create a pr #122170,
it modify fluter_windows.cpp to make windows application request through system proxy.
it now closed, becasue want to keep these app templates as minimal as possible.

but if anyone need way to send request by proxy you cloud checkout this pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: new feature Nothing broken; request for a new capability dependency: dart Dart team may need to help us engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list team-engine Owned by Engine team triaged-engine Triaged by Engine team
Projects
None yet
Development

No branches or pull requests