Sunday, August 31, 2014

[Win8.1]StreamSocket cannot suppot WPAD(Web_Proxy_Autodiscovery_Protocol)?

I have got a proxy connection problem, list 2 proxy types with different connected APIs below:


1. Connecting to standard proxy server, setup proxy server/port in IE, import via netsh and pass credential in IE


1.a System.Net.Http.HttpClient (connected, works fine)



handler = new System.Net.Http.HttpClientHandler();
handler.Proxy = WebRequest.DefaultWebProxy;
handler.Proxy.Credentials = CredentialCache.DefaultCredentials;
client = new System.Net.Http.HttpClient(handler);


1.b Windows.Web.Http.HttpClient (connected, works fine)



client = new Windows.Web.Http.HttpClient();


1.c StreamSocket (connected, works fine)




System.Uri uri = new Uri("http://ift.tt/xPIXNj;);
ProxyConfiguration pc = await NetworkInformation.GetProxyConfigurationAsync(uri);
// pc.CanConnectDirectly = false
StreamSocket client = new StreamSocket();




2. Connecting to WPAD proxy server, no setting required, pass the credential in IE, connected to internet (http://ift.tt/14xxxHA)


2.a System.Net.Http.HttpClient (connected, need to create the credential manually)



handler = new System.Net.Http.HttpClientHandler();
handler.Proxy = WebRequest.DefaultWebProxy;
handler.Proxy.Credentials = new NetworkCredential("username", "password");
client = new System.Net.Http.HttpClient(handler);


2.b Windows.Web.Http.HttpClient (connected, works perfect)



client = new Windows.Web.Http.HttpClient();



2.c StreamSocket (cannot connect, 407 Proxy authentication required)



System.Uri uri = new Uri("http://ift.tt/xPIXNj;);
ProxyConfiguration pc = await NetworkInformation.GetProxyConfigurationAsync(uri);
// pc.CanConnectDirectly = true <---- cannot detect the proxy server

StreamSocket client = new StreamSocket();



===


My question is that with the case 2.c, the CanConnectDirectly is true means StreamSocket cannot detect proxy to connect.


Is this a bug? or do i miss any settings?


===


PS: case 2, cannot detect proxy via netsh, too




netsh winhttp import proxy source=ieCurrent WinHTTP proxy settings:
Direct access (no proxy server).




Best Regards.





No comments:

Post a Comment