locked
Access denied when connecting to desktop app endpoint from metroUI

    Question

  • Is there some restriction I don't know about? I have a desktop app listening on a particular endpoint (ie, fixed ip address + port number). I have modified the StreamSocket sample app's code to connect on this endpoint:

        String^ remoteHostName = "98.111.222.333";
        String^ remoteServiceName = "63334";
        // Connect to the server (in our case the listener we created in previous step).
        task<void> connect(socket->ConnectAsync(ref new HostName( remoteHostName ), remoteServiceName, SocketProtectionLevel::PlainSocket));
        connect.then([this] (task<void> previousTask)

    Only the first arg of ConnectAsync was changed. It was changed to the explicit endpoint I wanted to connect to. But when running the modified StreamSocket sample, I get this exception on ConnectAsync:

    First-chance exception at 0x755056C4 (KernelBase.dll) in StreamSocket.exe: 0x40080201: WinRT originate error (parameters: 0x80070005, 0x00000040, 0x0389EE7C). First-chance exception at 0x755056C4 in StreamSocket.exe: Microsoft C++ exception:

    Platform::AccessDeniedException ^ at memory location 0x0389EDC0. HRESULT:0x80070005 Access is denied.

    What tools or steps can I take to track this access error down? By the way, I am using two different PCs to run this test.


     


    RT


    Friday, April 20, 2012 3:20 PM

Answers

  • Is the target computer on your intranet? If so you'll need the Private Networks (Client & Server) Capability rather than the Internet Capability.

    --Rob

    • Marked as answer by rtischer8277 Friday, April 20, 2012 9:57 PM
    Friday, April 20, 2012 8:58 PM
    Owner

All replies

  • I can set a breakpoint on the server-PC at CMyAsyncSocket::OnReceive and it never hits which means that the metro-PC running the modified StreamSocket sample is never executing the TCP connect statement. As a control I try a connect from another PC and the server-PC breaks fine at ::OnReceive.

    Maybe there is a network setting or outbound firewall permission that is stopping it from working.


    RT

    Friday, April 20, 2012 8:01 PM
  • Check the firewall and check that you have appropriate network capabilities declared in your manifest.
    Friday, April 20, 2012 8:16 PM
    Owner
  • Here is a shot of the package.manifest capabilities for my modified StreamSocket sample app:

    As one would expect, the StreamSocket capabilities are enabled. Also, the firewall lets the app through too:

    Is there another setting I need to pay attention to?


    RT

    Friday, April 20, 2012 8:54 PM
  • Is the target computer on your intranet? If so you'll need the Private Networks (Client & Server) Capability rather than the Internet Capability.

    --Rob

    • Marked as answer by rtischer8277 Friday, April 20, 2012 9:57 PM
    Friday, April 20, 2012 8:58 PM
    Owner
  • That did it. The target broke on CMyAsyncSocket::OnReceive. But I don't have any intranet here. These IP addresses are fixed unicast addresses meaning they are theoretically address accessible anywhere on earth. Nothing private about that.

    I have seen this Private vs Public distinction before in Microsoft's way of differentiating Internet connections when setting up a New Connection. There it seems like Public is like an internet café and Private is something else. Not necessarily Private as in intranet though.

    Anyway, thanks for the tips.


    RT

    Friday, April 20, 2012 9:57 PM