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

Support for Proxy in HttpClient in iOS #18635

Open
rolfbjarne opened this issue Aug 4, 2023 · 6 comments
Open

Support for Proxy in HttpClient in iOS #18635

rolfbjarne opened this issue Aug 4, 2023 · 6 comments
Labels
dotnet An issue or pull request related to .NET (6) feature A feature to be implemented
Projects
Milestone

Comments

@rolfbjarne
Copy link
Member

From @Syed-RI on Fri, 19 May 2023 13:23:03 GMT

Description

Please provide support/implementations to enable proxy in iOS

We are currently working on some enterprise applications which will be deployed to corporate devices via their MDM systems and they will enforce proxy on these devices. I was horrified seeing this bit of warning in my .NET MAUI app

Screenshot 2023-05-19 at 14 15 50

Bit of search revealed more horrors here: #14632

May be this is bit late for our project and we will have to abstract and have platform specific, unmanaged HttpClientHandlers to support proxy in iOS devices. Is there any proposal anywhere or official workaround? Apologies, if there is any and I have somehow missed it.

CC @davidortinau @PureWeen @Redth @rolfbjarne for visibility

Public API Changes

NONE

Intended Use-Case

To support and enable proxy in IHttpClientFactory for iOS devices

Copied from original issue dotnet/maui#15179

@rolfbjarne
Copy link
Member Author

From @Eilon on Thu, 03 Aug 2023 21:03:20 GMT

@rolfbjarne - does this seem like it should move to xamarin-macios or dotnet/runtime?

@rolfbjarne rolfbjarne added bug If an issue is a bug or a pull request a bug fix feature A feature to be implemented and removed bug If an issue is a bug or a pull request a bug fix labels Aug 4, 2023
@rolfbjarne rolfbjarne added this to the Future milestone Aug 4, 2023
@rolfbjarne rolfbjarne added the dotnet An issue or pull request related to .NET (6) label Aug 4, 2023
@rolfbjarne rolfbjarne added this to Technical Debt in .NET 8 - Themes Aug 4, 2023
@Syed-RI
Copy link

Syed-RI commented Aug 4, 2023

Glad to see that the issue is getting a bit of attention! ❤️

@rolfbjarne rolfbjarne removed this from Technical Debt in .NET 8 - Themes Sep 12, 2023
@rolfbjarne rolfbjarne modified the milestones: Future, .NET 9 Sep 12, 2023
@rolfbjarne rolfbjarne added this to Technical Debt in .NET 9 Sep 12, 2023
@M4ttsson
Copy link

Hi, just ran into this problem when migrating away from an old Xamarin project.

Since Proxy settings is not supported (anymore?), what would be the default behavior on iOS if not setting the proxy by code? Would the app respect any proxy from the system settings on the device, or try to go directly bypassing the proxy?

If bypassing, is there any workarounds to this since waiting until .NET 9 is not an option due to Xamarin EOL..

Thanks

@rolfbjarne
Copy link
Member Author

Hi, just ran into this problem when migrating away from an old Xamarin project.

Since Proxy settings is not supported (anymore?), what would be the default behavior on iOS if not setting the proxy by code? Would the app respect any proxy from the system settings on the device, or try to go directly bypassing the proxy?

If bypassing, is there any workarounds to this since waiting until .NET 9 is not an option due to Xamarin EOL..

Thanks

Yes, it will use the system proxy settings.

You might also be able to use the .NET http handler instead of the native one, by setting this in your csproj:

<PropertyGroup>
    <UseNativeHttpHandler>false</UseNativeHttpHandler>
</PropertyGroup>

There are a few downsides:

  • This will not use the system proxy (the app itself doesn't have access to the system proxy settings (in particular any passwords), so the .NET http handler doesn't either).
  • Battery usage may be higher.
  • Any network requests may be delayed/fail if the device is not connected to WiFi and the networking stack is sleeping because the .NET http handler won't wake the networking stack up again (https://learn.microsoft.com/en-us/dotnet/api/objcruntime.runtime.startwwan?view=xamarin-ios-sdk-12 is the fix for this).

@Axemasta
Copy link

Axemasta commented Jan 5, 2024

Now maui is in a relatively stable place, will there be support for this natively without the workaround described?

Using a proxy is important to an app I am working on and I dont want to lose the advantages of the native platform (there will be device proxies setup for example). Any idea of when this change would come into effect?

@rolfbjarne
Copy link
Member Author

@Axemasta no news yet, but we're trying to have a look at this in the .NET 9 time frame (no promises though).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet An issue or pull request related to .NET (6) feature A feature to be implemented
Projects
.NET 9
Technical Debt
Development

No branches or pull requests

4 participants