You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.NET MAUI iOS "Operation not supported on this platform" #1918
Describe the bug
In a .NET MAUI project running on iOS, creating an new instance of RestClient, throws an "Operation not supported on this platform" exception.
Android works as expected.
To Reproduce
Create new .NET MAUI project, add RestSharp nuget and create new RestClient object.
Run project on iOS configuration.
Expected behavior
Create a new instance of RestClient
Stack trace
at System.Net.Http.NSUrlSessionHandler.set_Proxy(IWebProxy value)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
--- End of stack trace from previous location ---
at System.Net.Http.HttpClientHandler.InvokeNativeHandlerMethod(String name, Object[] parameters)
at System.Net.Http.HttpClientHandler.SetProxy(IWebProxy value)
at System.Net.Http.HttpClientHandler.set_Proxy(IWebProxy value)
at RestSharp.RestClient.ConfigureHttpMessageHandler(HttpClientHandler handler)
at RestSharp.RestClient..ctor(RestClientOptions options, Action`1 configureDefaultHeaders)
at RestSharp.RestClient..ctor()
at MauiAuth0App.MauiProgram.CreateMauiApp() in /Users/vladsteer73/Work/R&D/dotnet-maui-auth0-app-main/MauiProgram.cs:line 32
Desktop (please complete the following information):
So adding if(handler.SupportsProxy) handler.Proxy = Options.Proxy; in RestClient fixes the instance creation. I've not yet tested that any further tho. Edit: Everything is working fine for me with that one line changed.
I tried v108.0.2 and it throws Timeout error.
Here's the exact error message, "The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing."
I'm not sure if I missed something, but it works perfectly fine in Android and in Windows platforms. This only happens in iOs platform.
Activity
FirewizzNL commentedon Sep 7, 2022
Got the same issue
vadd98 commentedon Sep 7, 2022
I have the same issue and I had to move to use the HttpClient in System.Net.Http
FirewizzNL commentedon Sep 8, 2022
Thanks, I will move to too. After a bit of searching it looks like this has been like this for ages
SebastianGrief commentedon Sep 8, 2022
Setting the
handler.Proxyin RestClient.cs:142 is causing that because custom proxies are not allowed in NSUrlSessionHandler:625-628So adding
if(handler.SupportsProxy) handler.Proxy = Options.Proxy;in RestClient fixes the instance creation.I've not yet tested that any further tho.Edit: Everything is working fine for me with that one line changed.dennisarriola commentedon Sep 19, 2022
Hello, I am experiencing this too. Hope this will be supported by RestSharp in their next release.
I'm using 108.0.1 by the way.
alexeyzimarev commentedon Sep 19, 2022
For's been there for ages is irrelevant as RestSharp doesn't work as it used to.
Thanks @SebastianGrief for the tip, mind opening a PR?
dennisarriola commentedon Sep 23, 2022
Hello,
Is the fix included in v108.0.2 release?
I am using the library from nuget.
alexeyzimarev commentedon Sep 23, 2022
https://github.com/restsharp/RestSharp/releases/tag/108.0.2
dennisarriola commentedon Sep 26, 2022
Hello @alexeyzimarev
I tried v108.0.2 and it throws Timeout error.
Here's the exact error message, "The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing."
I'm not sure if I missed something, but it works perfectly fine in Android and in Windows platforms. This only happens in iOs platform.
Do you have any idea on how to resolve this?
Thank you very much.
dennisarriola commentedon Sep 29, 2022
Hello,
We would like to follow-up, if .NET Maui iOS platform is already supported by this fix?
Thank you.
alexeyzimarev commentedon Sep 29, 2022
alexeyzimarev commentedon Sep 29, 2022
The fix resolved the "Operation not supported on this platform" issue with the proxy. That's what issue was about, and that's why it's closed.
dennisarriola commentedon Sep 30, 2022
I see. Thank you for reply @alexeyzimarev.
Guess .NET Maui iOs platform is still not supported.