C
C#3mo ago
Badboy

✅ MAUI on Android - problem with HttpClient Post Method

Hello guys, i am creating this post after more than week of learning and trying to solve it by myself. I have problem with reaching my WebApi with Post Method. There is no problem with Get Method. The error i'm getting is: System.ObjectDisposedException: 'Cannot access a closed Stream.' Which makes literally 0 sense for me. (i dislike that C# took away from us destructors and that may be consequence of it ?) Here is code
public static HttpClientHandler GetInsecureHandler()
{
HttpClientHandler handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =>
{
if (cert.Issuer.Equals("CN=localhost"))
return true;
return errors == System.Net.Security.SslPolicyErrors.None;
};
return handler;
}



private async Task<int> ConnectToApi_NotWorking()
{
HttpClientHandler insecureHandler = GetInsecureHandler();
HttpClient client = new HttpClient(insecureHandler);
client.Timeout = TimeSpan.FromSeconds(10);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"http://192.168.0.175:5297/api/Login");

request.Headers.Add("accept", "application/json");

request.Content = new StringContent("{\n\"login\":\"a\",\n\"password\":\"a\"\n}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
await DisplayAlert("AA", responseBody.ToString(), "ok");
return 0;
}
public static HttpClientHandler GetInsecureHandler()
{
HttpClientHandler handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =>
{
if (cert.Issuer.Equals("CN=localhost"))
return true;
return errors == System.Net.Security.SslPolicyErrors.None;
};
return handler;
}



private async Task<int> ConnectToApi_NotWorking()
{
HttpClientHandler insecureHandler = GetInsecureHandler();
HttpClient client = new HttpClient(insecureHandler);
client.Timeout = TimeSpan.FromSeconds(10);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, $"http://192.168.0.175:5297/api/Login");

request.Headers.Add("accept", "application/json");

request.Content = new StringContent("{\n\"login\":\"a\",\n\"password\":\"a\"\n}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
await DisplayAlert("AA", responseBody.ToString(), "ok");
return 0;
}
I will add full git project if needed. There is no problem with implementation of Login in API (tested with same code run on Windows and using Postman)
183 Replies
Badboy
Badboy3mo ago
GitHub
GitHub - Badboy-2/MAUI_HttpClient: Showcase of problem i encountere...
Showcase of problem i encountered using HttpClient in MAUI - Badboy-2/MAUI_HttpClient
Stefanidze
Stefanidze3mo ago
Where in the code you are getting the exception? There is a lot of things that can be disposed here...
Badboy
Badboy3mo ago
@Stefanidze In MainPage.xaml.cs line 66 or just
HttpResponseMessage response = await client.SendAsync(request);
HttpResponseMessage response = await client.SendAsync(request);
it skips to 'return 0;' then throws System.ObjectDisposedException: 'Cannot access a closed Stream.' Everything is in same context... i don't really understand what is happening
Badboy
Badboy3mo ago
Image just to portray, and also values from debugger
No description
Badboy
Badboy3mo ago
they are disposed too early but how come, they are
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
I know, but i was trying to set up perfectly clear code. I created a project, so everyone could fork, and try to run this on andro emulator or take function as whole
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
it's not main code and no, it won't
Stefanidze
Stefanidze3mo ago
Have you tried?
Badboy
Badboy3mo ago
already tried to make it only thing in program
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
i tried that man it doesn't work, my english is bad or what
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
Because i tired to show that it doesn;t work in any method
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
Okay
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
that's only one of approaches i know it's utterly terrible
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
kk, give me like 20 minutes and i will clean it up
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
Maui is bug as whole
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
Yeah, but it only doesn't work on post method
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
you could put get into that bullshit and it works
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
put GET method*
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
GitHub
MAUI_HttpClient/MAUI_HttpClient at master · Badboy-2/MAUI_HttpClient
Showcase of problem i encountered using HttpClient in MAUI - Badboy-2/MAUI_HttpClient
Badboy
Badboy3mo ago
The middle one with suffix _working still works, others do not It doesn't even try to execute reading from response, object are just dying
Asthreya.
Asthreya.3mo ago
Did you enabled cors on the api? I don't see this problem related to maui tho
Badboy
Badboy3mo ago
Sorry... did i enable what ? Do you want me put WebAPi project to git ?
Asthreya.
Asthreya.3mo ago
Wait...
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
Also i think it would be sus, if it would be problem on API site, bc it works on windows emulator and swagger postman also Literally below you have version you desire which also doesnt work
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
YES
Asthreya.
Asthreya.3mo ago
app.UseCors(x => x
.AllowAnyMethod()
.AllowAnyHeader()
.SetIsOriginAllowed(origin => true)
.AllowCredentials());
app.UseCors(x => x
.AllowAnyMethod()
.AllowAnyHeader()
.SetIsOriginAllowed(origin => true)
.AllowCredentials());
I usually add this on my webapi builder but I bet this method is risky. Ask @TeBeCo
Badboy
Badboy3mo ago
for showcase It's not duplicated bc it works diffrent way i don't have anything working, so it's good to try like ... 2 options at once ? not only one ?
Asthreya.
Asthreya.3mo ago
Because it accepts any method anywhere
Badboy
Badboy3mo ago
Is this wrong approach ? Will try that, give me sec
Asthreya.
Asthreya.3mo ago
Its good for learning how webapi works. which i still do @TeBeCo helps a lot of devs here and I'm sure he already forgets that he helped me before Thanks again tho
Badboy
Badboy3mo ago
Is it duplication if it works diffrently but result is same ? I mean i know in PROD it is, but this isn't PROD. Should i just go with one instead of 2 ? I thought showcasing is somehow good ?
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
No problem 🙂 Take your time, goodluck also System.ObjectDisposedException: 'Cannot access a closed Stream.' Stills pops up, but i noticed NetworkSecurityConfig] No Network Security Config specified, using platform default
Badboy
Badboy3mo ago
No description
Asthreya.
Asthreya.3mo ago
Does it work on a non-maui project?
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Asthreya.
Asthreya.3mo ago
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true" android:usesCleartextTraffic="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true" android:usesCleartextTraffic="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
I added
android:usesCleartextTraffic="true"
android:usesCleartextTraffic="true"
Asthreya.
Asthreya.3mo ago
No description
Asthreya.
Asthreya.3mo ago
Here
Asthreya.
Asthreya.3mo ago
Stack Overflow
No Network Security Config specified, using platform default - Andr...
I am trying to make a database via 000webhost.com. I keep getting this message showing in the event log whenever I run the app from android studio. Does anyone knows how to solve this problem? Much
Asthreya.
Asthreya.3mo ago
Open it with xml text editor Does this also shows when you didn't add cors?
Badboy
Badboy3mo ago
Yes
Asthreya.
Asthreya.3mo ago
This one?
Asthreya.
Asthreya.3mo ago
No description
Asthreya.
Asthreya.3mo ago
Try this out
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
MAUI only does webview if you're doing say blazor over maui
Asthreya.
Asthreya.3mo ago
But its still native
leowest
leowest3mo ago
or when u you to auth against oauth
Asthreya.
Asthreya.3mo ago
Just the view isn't
leowest
leowest3mo ago
we are talking about the need of CORS
Asthreya.
Asthreya.3mo ago
Oh so I guess it doesn't need cors Brb dinner
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
No :/ you will have to put your ip in API config files is it acceptable ?
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
Okay, i'm on it
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
Thank you guys for your time, i really do appreciate it
Asthreya.
Asthreya.3mo ago
Have you tried this?
Badboy
Badboy3mo ago
Yea, mine AndroidManifest.xml looks like this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="MAUI_TEST"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="25" android:targetSdkVersion="25" />
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="MAUI_TEST"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="25" android:targetSdkVersion="25" />
</manifest>
Asthreya.
Asthreya.3mo ago
No description
Badboy
Badboy3mo ago
wait what
Asthreya.
Asthreya.3mo ago
I added
android:usesCleartextTraffic="true"
android:usesCleartextTraffic="true"
The one i cloned looked different on yours but try to add this
Badboy
Badboy3mo ago
It is there
Asthreya.
Asthreya.3mo ago
Where?
Badboy
Badboy3mo ago
I accidentally pasted code from my opened copy of this project
Asthreya.
Asthreya.3mo ago
Oh it's in the "branch" branch
Badboy
Badboy3mo ago
yea, im stupid
Asthreya.
Asthreya.3mo ago
Did it worked?
Badboy
Badboy3mo ago
No 😦 But i believe it was necessary step whe had to took. We have to kinda rip all security apart, to see whats going on imho
leowest
leowest3mo ago
@Badboy you also need to add
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
To your csproj because u have a lot of missing libraries being loaded
leowest
leowest3mo ago
No description
Badboy
Badboy3mo ago
https://github.com/Badboy-2/MAUI_HttpClient https://github.com/Badboy-2/WebAPI_ForMaui Replace this string in both project 192.168.0.175 with your ip (Ctrl+H ready, 0 risk involved :p) Additionaly i think you have to add exceptions to firewall for port 5297 and 7258 / turn off firewall
GitHub
GitHub - Badboy-2/MAUI_HttpClient: Showcase of problem i encountere...
Showcase of problem i encountered using HttpClient in MAUI - Badboy-2/MAUI_HttpClient
GitHub
GitHub - Badboy-2/WebAPI_ForMaui
Contribute to Badboy-2/WebAPI_ForMaui development by creating an account on GitHub.
Badboy
Badboy3mo ago
Thanks! Will add it in moment This powershell comamand will create exceptions in your firewall
$ports = @(5297, 7258)
foreach ($port in $ports) {
New-NetFirewallRule -DisplayName "Custom Inbound Rule for Port $port" `
-Description "Allows inbound traffic on port $port" `
-Direction Inbound `
-LocalPort $port `
-Protocol TCP `
-Action Allow
New-NetFirewallRule -DisplayName "Custom Outbound Rule for Port $port" `
-Description "Allows outbound traffic on port $port" `
-Direction Outbound `
-LocalPort $port `
-Protocol TCP `
-Action Allow
}
$ports = @(5297, 7258)
foreach ($port in $ports) {
New-NetFirewallRule -DisplayName "Custom Inbound Rule for Port $port" `
-Description "Allows inbound traffic on port $port" `
-Direction Inbound `
-LocalPort $port `
-Protocol TCP `
-Action Allow
New-NetFirewallRule -DisplayName "Custom Outbound Rule for Port $port" `
-Description "Allows outbound traffic on port $port" `
-Direction Outbound `
-LocalPort $port `
-Protocol TCP `
-Action Allow
}
UDP too ? :andyHmm:
leowest
leowest3mo ago
@Badboy your problem have nothing to do with usesCleartextTraffic because that is used when you're making a non-https connection but you're trying to access https. On top of that you want to access a localhost certified ssl, so if you wrap the httpclient with a try and catch u will most likely get a Trust anchor for certification path not found. error that backs that up what you would have to do is create a custom android message handler with your internal api ip i.e.:
#if ANDROID
internal sealed class CustomAndroidMessageHandler : Xamarin.Android.Net.AndroidMessageHandler
{
protected override Javax.Net.Ssl.IHostnameVerifier GetSSLHostnameVerifier(Javax.Net.Ssl.HttpsURLConnection connection)
=> new CustomHostnameVerifier();

private sealed class CustomHostnameVerifier : Java.Lang.Object, Javax.Net.Ssl.IHostnameVerifier
{
public bool Verify(string? hostname, Javax.Net.Ssl.ISSLSession? session)
{
return
Javax.Net.Ssl.HttpsURLConnection.DefaultHostnameVerifier.Verify(hostname, session)
|| hostname == "10.0.0.1" && session.PeerPrincipal?.Name == "CN=localhost";
}
}
}
#endif
#if ANDROID
internal sealed class CustomAndroidMessageHandler : Xamarin.Android.Net.AndroidMessageHandler
{
protected override Javax.Net.Ssl.IHostnameVerifier GetSSLHostnameVerifier(Javax.Net.Ssl.HttpsURLConnection connection)
=> new CustomHostnameVerifier();

private sealed class CustomHostnameVerifier : Java.Lang.Object, Javax.Net.Ssl.IHostnameVerifier
{
public bool Verify(string? hostname, Javax.Net.Ssl.ISSLSession? session)
{
return
Javax.Net.Ssl.HttpsURLConnection.DefaultHostnameVerifier.Verify(hostname, session)
|| hostname == "10.0.0.1" && session.PeerPrincipal?.Name == "CN=localhost";
}
}
}
#endif
then you would need to add that handler to your httpclient i.e.:
#if ANDROID
HttpMessageHandler? handler = new CustomAndroidMessageHandler
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =>
{
if (cert != null && cert.Issuer.Equals("CN=localhost"))
return true;
return (int)errors == 0;
}
};
_httpClient = new HttpClient(handler);
#else
_httpClient = new HttpClient();
#endif
#if ANDROID
HttpMessageHandler? handler = new CustomAndroidMessageHandler
{
ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =>
{
if (cert != null && cert.Issuer.Equals("CN=localhost"))
return true;
return (int)errors == 0;
}
};
_httpClient = new HttpClient(handler);
#else
_httpClient = new HttpClient();
#endif
so in my case my api internal ip is 10.0.0.1 in your case you have to update it to yours
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
@TeBeCo I mean u wouldn't need any of this if u had the api was else where
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
u also dont need any of this for local
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
u can't target iOS afaik u need a device but I haven't start doing iOS so dont take my word for it
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
just change your targat to android I can't read a thing in your video sorry its too small
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
that would be WSL Android not google emulator AFAIK
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
mmm weird mine doesnt say WSA maybe because ur on w11?
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
I dont have that
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
so I guess vs uses a completely different thing for android on w11
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
emulator is pretty fast for me never had issues
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
yeah I dont disagree I never had the change to try wsa so I dont know how different it is unhappily
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
I honestly dont know how it runs with WSA
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
with emulator it starts everything for u
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
that would have been a bliss if the emualtor had that ah ok it recognizes it by default too nice
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
too bad they taking it down I wonder how fast it is too
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
that looks about the same as the emulator thou
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
no I mean the ui
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
no, I mean the screenshot above is the same app u use on either wsa or the emulator to create the device its not different
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
mm I just use 4096 there instead
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
let me chck
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
ah no on that one it was default to
leowest
leowest3mo ago
No description
leowest
leowest3mo ago
No description
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
ah
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
it does allow for both
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
I dont have a mic for it but yeah your right it doesn'tr accept G never paid attention to it I never had to mess with that beyond creating the device
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
Deploy: 0 succeeded, 0 failed, 1 skipped?
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
I dont know let me clone his repo to try
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
but u originally loaded the last project he sent in right
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
sure but it builds without doing anythng thou
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
>Done building project "MAUI_HttpClient.csproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Rebuild completed at 12:26 and took 59,498 seconds ==========
>Done building project "MAUI_HttpClient.csproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Rebuild completed at 12:26 and took 59,498 seconds ==========
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
No description
leowest
leowest3mo ago
well it all works here to deploy too
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
im latest preview everything it all run without touching anything
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
sure, and all I am saying is that I didn't have to do anything to run it, so I dont know why u had to vs that
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
I dont have net7 either
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
No description
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
that's why I dont understand why ur having such issues
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
No description
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
leowest
leowest3mo ago
since the answer was burry, @Badboy just for clarity I provided the solution from there so u can read it: https://discord.com/channels/143867839282020352/1221703280204451932/1221830944231657603
MODiX
MODiX3mo ago
leowest
<@1221689581276106802> your problem have nothing to do with usesCleartextTraffic because that is used when you're making a non-https connection but you're trying to access https. On top of that you want to access a localhost certified ssl, so if you wrap the httpclient with a try and catch u will most likely get a Trust anchor for certification path not found. error that backs that up
React with ❌ to remove this embed.
Badboy
Badboy3mo ago
How come you think so ? In LAN firewall rules do apply still. Am i missing something ? Or did you mean local - like in local device (not Local network)
leowest
leowest3mo ago
yeah my bad if your api is on a different pc then yes you might need it, for local u dont but either way u can place the sealed class in its own file in the android platform folder and then use from the main code and it should work
Badboy
Badboy3mo ago
Oh got it, thank you guys soo much for your intel. I appreciate, tomorrow morning( in like 10 hours) i will sit to this after some sleep. Even if it won't work, i still learnt a huge deal of things 🙂 For that i am grateful
leowest
leowest3mo ago
I mean I tried it myself so I hope it works 😉 I did not try it from a machine within my local network but assuming u can access it via the browser u should be able to reach it just fine from the app the problem is that it expects the url to be localhost because its the certificate but its not so you need to further add the hostname verification to your local ip I also strongly recommend u to wrap those under #if DEBUG as well u dont want that to acciddentally land on the final product
Badboy
Badboy3mo ago
@leowest Thank you very much 🙂 it DOES WORK and for SSL also ;_; i tried to use nonSSL connections bc of marathon-long threads i saw about this problem on forums (it said SSL version mismatch makes it impossible to connect, thus using nonSSL) I kinda don't believe still, after all this time. You guys really make it. To everyone involved
Badboy
Badboy3mo ago
@TeBeCo Also i will try your code tonight on diffrent platform (i truly do not want to mess up what is working) (and i'm afraid of installing newer versions of .NET, 99% i'm just dumb not doing it right away, but caution is too strong in me) (so i will do it firstly not on my DevEnv)
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
Yeah sure, good idea 😄
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
names of files ?
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
or objects etc. okay
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
Badboy
Badboy3mo ago
I come from C++, and was pretty sure, that underscore is safe Good to know it isn't Do you perhaps have any clue why could underscore mess things up ? The idea of underscore was to not mess things up, i believe Like parser thing, or smtn ?
leowest
leowest3mo ago
no worries, yeah it was not simple because the output window was not giving any useful information once I wrapped the error in a try catch it gave me a complete different error message which was what lead me to the answer the only thing the output spotted was that u needed to embed the libraries into the apk nevertheless glad it worked for u 🙂 $close
MODiX
MODiX3mo ago
Use the /close command to mark a forum thread as answered