Why does StreamSocket::ConnectAsync set up two TCP connections when proxy is configured in system?

Hello, Dear all,
Per my test, the proxy for HTTPS will be selected as the actual used one for the out-going packets if we do the following test in an corporate network environment. Two connections will be set up: one is with the proxy, the other one is with the target address.
Some info about my env:
1. the configured proxy could only be accessed in the corporate network;
2. the target host has both private and public IPs;
3. I don't check whether there is proxy configured in code.
4. the issue could only occurr in the private network; If I do the test out of the corporate network, the behavior is correct because no proxy is configured. But I am not sure whether the issue would occur if there would be a usable proxy configured.
The repro steps are:
1. Create a Windows Store App project with VS2013. The testing code is pretty simple as the following:
using namespace Windows::Networking::Sockets;
StreamSocket^ streamSock = ref new StreamSocket();
IAsyncAction ^sconn = streamSock->ConnectAsync(
ref new Windows::Networking::HostName("10.1.2.3"), "56789",
SocketProtectionLevel::PlainSocket);
The target address and port (10.1.2.3:56789) could be any meaningful or bad one. We only need to observe the packet sent out from the client side in the following steps.
2. Configure the proxy in Internet Options -> Connections -> LAN Settings -> Advanced -> Secure. Give a good proxy/port to it;
2.1. Run the program and capturing the packet from Wireshark or other tools.
   ==> You will see that a HTTP request with header "CONNECT" is sent to the proxy. That's to say, the client will connect to the proxy.
   ==> You will also see that the client side also sent out a TCP SYN packet to the remote target address (10.1.2.3:56789).
3. Disable or remove the proxy setting;
3.1. Run the program and capturing the packet from Wireshark or other tools.
   ==> You will see that there would be no HTTP request sent out.
I am using Win8.1/VS2013 and the system is up-to-date... I am not sure the behavior is designed as this, or it is a bug of the StreamSocket?
BTW: I didn't use Windows::Networking::Connectivity::NetworkInformation::GetProxyConfigurationAsync on purpose.
For the classical WinSock, we could only see the TCP SYN packet in step 2. That's to say, the behaviors between StreamSocket and WinSocket are different.
Thank you all.

A workaround to avoid proxy connection requests from being sent out is to use the
ConnectAsync(Hostname, String, SocketProtectionLevel,
NetworkAdapter) method with a specific adapter. The proxy-related logic is disabled when a specific network adapter is selected.
You can retrieve the main active network adapter by calling GetInternetConnectionProfile() and then referencing the NetworkAdapter property of the returned information:
ConnectionProfile^ connectionProfile = NetworkInformation::GetInternetConnectionProfile();
NetworkAdapter^ adapter = connectionProfile->NetworkAdapter;
You could also enumerate all possible adapters and try to connect on each of them, one by one:
for each (HostName^ localHostInfo in NetworkInformation::GetHostNames())
if (localHostInfo->IPInformation != nullptr)
NetworkAdapter^ adapter = localHostInfo->IPInformation->NetworkAdapter;
// Attempt to connect with this adapter.

Similar Messages

  • HT1600 why does the apple TV say theres no connection when I have it?

    Why does my apple TV want to recognize my internet password? and what does -39092 mean?

    Hi MLFO!
    I have some information here that I believe will help you troubleshoot this issue a little further. The article is about Wi-Fi connections and the Apple TV, and can be found here:
    Apple TV (2nd and 3rd generation): Troubleshooting Wi-Fi networks and connections
    http://support.apple.com/kb/TS4546
    Follow the steps provided in that article and you should be well on your way toward resolving this issue. It may also be necessary or helpful to reference this article as well, which contains some useful settings for your Wi-Fi router so that it will connect to iOS and OS X devices more easily:
    iOS and OS X: Recommended settings for Wi-Fi routers and access points
    http://support.apple.com/kb/ht4199
    Thanks for coming to the Apple Support Communities!
    Regards,
    Braden

  • Why does FiOS internet take so long to connect when I boot my computer?

    Windows Vista Home Premium Service Pack 2.    M424WR modem/router.    Every time I turn on my computer or even if I reboot, internet takes up to 2 minutes to be able to use.    My computer doesn't detect any internet connection until, it seems, it's good and ready.   The modem is NEVER turned off and everything else in the house dependant on the internet connection doesn't have a problem.   Phones, wireless lap tops, or the PS3.    Why does it do this?  I have put IHA messenger on manual in startup.  But I still get the same problem.   Is there any way to fix this?  It's so annoying. 
    And Please, Verizon support, don't send me any private messages that say to call verizon support or asking me to send you my verizon account info.  I absolutely HATE that when you guys do that.   I'm not spending half my day on hold, and you don't need to know that to answer why the computer is taking so long to find the internet connection.   If you don't know why it's doing it, then say you don't know why, or better yet, don't even respond at all.  {Please keep your posts courteous}

    I have both an XP machine and a Win7 laptop. Both take time after booting to access the network.  The culprit is Norton (Symantec). In both cases it runs a security check BEFORE it allows network access.
    You may not have Symantec products installed, but if you have any other antivirus software it it probably doing the same thing.

  • Why does itunes always show my iphone as connected when it is not

    When I plug in one of our Apple devices to sync to our home computer, etc., iTunes shows the device I want to sync, but it also always shows my iphone as plugged in too. (At the top where it says Devices). Not a big deal, but is there a way to remove this instead of always hitting the eject button?

    Do you have wifi sync enabled for those devices?
    Select the device, click the Summary tab.
    If it is enabled, there's no need to eject the device, even with the cable plugged in.

  • Why does my newsstand take up two spots?

    why does my newsstand take up two spots?

    well, i found out why, and here it is...
    there was an invisible folder entitled "volumes" which contained 300 gb worth of unsuccessful time machine transfers. i would not have been able to ever find it or know of it's existence (since it never returned any search results) had it not been for some innocuous little microsoft word virus. (i ran virus check and found multiple copies of the same word file infected, and was able to open each in finder view to follow them back to their originating folder(s), and the rest is history)

  • Why does 'Guest User' appear in a foreign language when logged in as guest?

    Why does 'Guest User' appear in a foreign language when logged in as guest? It's not a major problem but it would be nice to be able to fix it, and to understand how it happened.
    Everything else is in English (or set to English) as far as I can see, and my Macbook is only a couple of weeks old. All system updates have been performed and permissions have been repaired.
    It displays it in Finnish (Suomi) as 'Vierastilin käyttäjä' only when logged in, in the System Preferencess user list and apple menu (where you would normally select 'Log Out Guest User'). I cant find anyone else with the same problem online. I am in the UK, purchased the Macbook on the UK Apple Store online, and I have never been to Finland or selected anything to do with Finland or its language. Everything else is in English.
    I should add that 'Vierastilin' showed up instead of 'Guest User' on the OSX login screen on the first day I had the Macbook, but this seemed to fix itself somehow soon after.
    A couple of photos to illustrate the problem that still exists are attached.

    Thanks for the reply. I only have English - Primary but I guess I could add Finland and then delete it...
    Okay, tried that, lots of variations including deleting all other languages and only using Finnish, and then using only British English etc - when guest is in Finnish the whole lot becomes Finnish/Suomi (see attached photos to compare with the ones above) - then when you delete Finnish and go back to English, everything is Englisg apart from 'Vierastilin käyttäjä' as above.
    Any other ideas where it stores that info - is there a dodgy preference file somewhere which needs zapping?

  • HT1688 why does my 3gs say activation server temp unavailable when updating firmware?

    why does my 3gs say activation server temp unavailable when updating firmware? it also tells me no service in the top left corner please help i cant get out of activation screen

    Only fixed this in the last day or two . . .with this!
    https://discussions.apple.com/thread/3588501?start=0&tstart=0

  • Why does Messages still send my txt via SMS when I have the "send as SMS" option turned off?

    Why does Messages still send my txt via SMS when I have the "send as SMS" option turned off?

    I haven't missed any point, but you don't get it.
    If people take "Send as SMS" being turned off as the iPhone shoiuld not be sending SMS messages without reading this text that is included below the option:
    Send as SMS when iMessage is unavailable. Carrier messaging rates may apply.
    They are idiots.
    But you're saying you have this other piece of information that tells you that this option only applies to two iphones exchanging txt.  Where did you obtain such information?
    Copied from my previous post.
    Under the Send as SMS option, the following is available:
    Send as SMS when iMessage is unavailable. Carrier messaging rates may apply.
    You should check available text below an option such as this so you know what it does.

  • Why does the sync button not work in itunes when my ipod touch is connected

    why does the sync button not work in itunes when my ipod touch is connected?

    It's working for me in Acrobat XI:
    I'd try logging into Acrobat.com from your browser, and log in with your Adobe ID. There may be a problem there:
    workspaces.acrobat.com

  • HT1420 Why does my computer keep asking to be authorized when i put my iphone on the charger?

    Why does my computer keep asking to be authorized when i put my iphone on the charger?

    Authorization and Deauthorization
    See iTunes Store- About authorization and deauthorization for Macs.
    See How to Authorize or Deauthorize iTunes | PCWorld for Windows.
    In iTunes you use the Authorize This Computer or De-authorize This Computer option under the Store menu in iTunes' menubar. For Windows use the ALT-S keys to access it.
    More On De-authorizing Computers (contributed by user John Galt)
    You can de-authorize individual computers, but only by using those computers. The only other option is to "de-authorize all" from your iTunes account.
      1. Open iTunes on a computer
      2. From the Store menu, select "View my Account..."
      3. Sign in with your Apple ID and password.
      4. Under "Computer Authorizations" select "De-authorize All".
      5. Authorize each computer you still have, as you may require.
    You may only do this once per year.
    After you "de-authorize all" your authorized computers, re-authorize each one as required.
    If you have de-authorized all computers and need to do it again, but your year has not elapsed, then contact: Apple - Support - iTunes - Contact Us.

  • Why does it say rogers 3g on my ipad when it should say rogers 4g?

    why does it say rogers 3g on my ipad when it should say rogers 4g

    You may be in an area where Rogers doesn't yet have 4G. If so, the iPad will drop back to 3G and will display that to let you know you're running on the older network.

  • Why does aperture convert my raw files to jpegs when I import them from iPhoto?

    Why does aperture convert my raw files to jpegs when I import them from iPhoto?

    It doesn't.
    When you import  Raw to iPhoto the app makes a jpeg preview of the Raw automatically. When you import from iPhoto then Aperture brings over both versions.
    Regards
    TD

  • Why does it keep saying that an error occurred when downloading iOS 8?

    Why does it keep saying that an error occurred when downloading iOS 8?

    Have you tried updating via iTunes? I find that way's more reliable - I've never had any problems with updating that way.

  • Why does my itunes say "Itunes could not connect to the iphone because the device timed out"? I just want to sync my iphone with my itunes. please help

    why does my itunes say "Itunes could not connect to the iphone because the device timed out"? I just want to sync my iphone with my itunes. please help

    If you are using a USB hub, don't. Connect directly to the computer. Disconnect all other USB devices except for keyboard and mouse.

  • Why does my 3gs say activation server temp unavailable when updating firmware?

    why does my 3gs say activation server temp unavailable when updating firmware? it also tells me no service in the

    It could be related to activation servers being busy, or you can check this support document for assistance. http://support.apple.com/kb/TS4268

Maybe you are looking for

  • Pdf report doesn`t show cyrillic letters

    Hi everyone. For generate report I begin to use Exaprom PDF https://decibel.ni.com/content/docs/DOC-10952 . But there are I find a bug. I try to insert russian letters to the pdf as text, there is no error. But when I open pdf documents, there is not

  • PC-UI : long text of messages

    On clicking the details of the messages we get only the static long text but not the messages which are collected in from other sytems say R/3.

  • Saving changes

    Hi, I realize that edits to photos are supposed to be saved automatically, but mine are not. I edit a photo, and the changes show up in the thumbnail, but when I open the thumbnail in an edit window, I get the original picture file. I want to see an

  • Apple keyboard driver for Windows XP without running Bootcamp constantly

    I just reinstalled Bootcamp/WindowsXP and wanted to know if there was a way I can get a driver for JUST the keyboard working.  I don't use any of the MBP F key functions like backlighting and volume so don't like having the bootcamp processes always

  • Face Recognition problem...

    I always get a failed logon when using the face recognition for my u405d-s2902 i set the security low already but still get failed.. can you give me some tips how this face recognition works? pls help thanks...