uncle_scrooge
uncle_scrooge

Reputation: 429

httpclient issue in UWP

I am using System.Net.Http.HttpClient, It is showing some weird errors.Below is my code.

public async static Task SearchYoutube(string query, int count)
{
    try
    {
        string format = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=20&q=mere&key=XXXXXXXXXXXXXXX&pageToken=";

        HttpClient client = new HttpClient();
        // System.Net.ServicePointManager.EnableDnsRoundRobin = true;
        var html = await client.GetStringAsync(format);
        string ht = html.ToString();
    }
    catch (Exception ex)
    {
        //var resp = ex.Response as HttpWebResponse;
    }
}

Exception- The text associated with this error code could not be found.

An error occurred in the secure channel support.

My workarounds- hrresult- -2147012739(I think this WINNETI_SCHANNEL_ERROR)

below is the stacktrace-

at System.Net.Http.HttpClientHandler.d__86.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Net.Http.HttpClient.d__58.MoveNext()

Steps I have taken to resolve the issue:

1.Turned off Firewall.

2.Given all available options in INTERNET OPTIONS(SSL,TLS etc.)

3.The link you have provided ,I have already checked that.

4.Tried Windows.Web.http instead of system.net.http

5.Used Handlers and Certificates

6.Checked capabilities-Internet(Client),Internet(Client and server) ,Private Networks(Even I checked all of the capabilities and tried but same result)

7.I have created a console application and pasted same codes,Worked like a charm.The only problem is ,it is not working in uwp platform and specifically in my system(It is working in my friend's system).

8.Tried all available option available in internet.

Upvotes: 8

Views: 1149

Answers (2)

flamewave000
flamewave000

Reputation: 616

Unfortunately not enough rep to comment; Ivan Ičin likely correct if you are using the Windows Insider Fast Ring build, the secure connection will have problems with Google servers. This has been fixed in their latest release, Build 15025, that came out today (Feb. 1, 2016).

Release Note:

Windows Insiders should no longer have trouble connecting to certain Google sites due to an implementation of a new security model being rolled out to further enhance user security.

Upvotes: 4

Ivan I
Ivan I

Reputation: 9990

You are probably using Windows Insider builds. Google sites don't work in Insider builds because of the current security policies that will be fixed. You can read the text for Edge here: https://mspoweruser.com/cant-access-youtube-gmail-insider-builds-microsoft-working/ but the same goes to HttpClient.

Upvotes: 5

Related Questions