UWP Enable local network loopback
Asked Answered
G

1

31

I wrote a UWP-App and after generating and installing the .appxbundle, every time I start the App I get a net_http_client_execution_error. The App is starting and running fine, when started in Visual Studio 2015. So there is no chance for me to get the problem, if I debug the app.

Update:
By default Windows restricts apps to reach the localhost (127.0.0.1). I have running a couch database there. This couch database should run there for our costumers as well. Is it possible to allow a App to reach the localhost (enable local network loopback)?

Grecize answered 21/10, 2015 at 12:47 Comment(5)
What Capabilities have you set in your Package.appxmanifest?Middleoftheroader
Internet (Client), Internet (Client & Server), Private NetworksGrecize
The exception is throw while getting the response in request.GetResponseAsyncGrecize
Have you tried seeing what is going over the wire, with a tool like Fiddler?Middleoftheroader
Thats exactly what I did the last minutes. And I found the problem. Windows restricts apps to reach your localhost (127.0.0.1). I try to reach a local couch database. I will change my question to make it clear.Grecize
C
58

For a line of business app use the checknetisolation.exe tool to grant the app a loopback exception.

To enable loopback use this command:

c:\>checknetisolation loopbackexempt -a -n=<package family name>

To disable loopback use this command:

c:\>checknetisolation loopbackexempt -d -n=<package family name>

The package family name for a UWP app can be found in several places: Visual Studio shows it in Package.appxmanifest editor on the packaging tab, PowerShell's get-appxpackage cmdlet displays it, etc. It will look something like "MyPackage_edj12ye0wwgwa"

In some cases loopback exemption will work for some time and then stop working. In this case you might need to run the following command to clean/remove all exemptions and then add them back one by one to get back in a good state. (from Pawel Sledzikowski's comment)

c:\>checknetisolation loopbackexempt -c

There is a whitepaper with more details at https://msdn.microsoft.com/en-us/library/windows/apps/dn640582.aspx

Carlocarload answered 21/10, 2015 at 15:24 Comment(7)
this works fine, but you have to replace the -d with -a to add your app. -d will delete it from the listGrecize
This restriction looks a little buggy. Turning loopback off and on helped me personaly at one time during development. During development my app suddenly got timeouts for the local tcp connection. Looked up "Allow local network loopback" in project properties which was activated. Installed loopback.codeplex.com to lookup the entry itself. Still actived. Tried the good old, turn off and on again trick, which solved my problem.Phytogenesis
In my case loopback exemption was working for me for some time and then, from unknown reasons, it suddenly stopped working. I was pulling my hairs out of a head how to make it working again but unfortunately no dice. Finally, I discovered that cleaning all exemptions via checknetisolation loopbackexempt -c command and then adding them one-by-one again works as expected.Montagu
Pawel, your comment deserves to be incorporated into the answer. I too was pulling out my hair until I saw your comment. It looks like the checknetisolation exemption table can become corrupt, and the only way to fix it is to clear all exemptions. Deleting and re-adding one's exemption alone does not work. I didn't even know about the '-c' parameter until I way your comment (which needs to be massively upvoted by all those questioning their sanity). Interestingly, when the table gets corrupted, even Edge cannot access the exempted address (but Firefox and Chrome can).Uncaredfor
Maybe it is a bit too late but thanks @PawelSledzikowski for your comment. As zax mentioned, your comment deserves to be incorporated into the answer, I too feel the same. Thanks for sharing.Pictish
Note the latest info (as of April 2020) is in the "Loopback" section of this MSDN documentThurmanthurmann
For a UWP client to connect to a Win32 server I did not need CheckNetIsolation simply giving it that privateNetworkClientServer capability was enough. Not sure that's enough this days or is it because my development machine is in Test Mode or something.Stirps

© 2022 - 2024 — McMap. All rights reserved.