Connecting two local uwp Apps on same machine - networking

Im trying to let two uwp apps (windows 10 apps) communicate while running on the same machine. The Apps already can communicate when run on different hosts, so the code is working (both apps are enabled to communicate in local and public networks declared in their manifest files).
When running on the same host however, the client application is not able to connect to the server.
Im using Visual Studio 2015 Community Edition Update 3 for developing.
Under ProjectSettings->Debug->Allow local network loopback is checked.
I tried to ad an LoopbackExempt via commandline (for both apps):
checknetisolation LoopbackExempt -d -n=<packagefamilyname>
But still not working.
The code im using (thought might not be relavant)
Serverside code:
var listener = new StreamSocketListener();
listener.ConnectionReceived += Listener_ConnectionReceived1;
await listener.BindServiceNameAsync("20000", SocketProtectionLevel.PlainSocket);
Clientside code:
StreamSocket socket = new StreamSocket();
_hostName = <hostname/ip>;
await socket.ConnectAsync(new HostName(_hostName), "20000",SocketProtectionLevel.PlainSocket);

The loopback exemption will allow the app to connect out to the local system as a client, but it won't let the app receive local connections as a server.
See the Note on MSDN in the article How to enable loopback and troubleshoot network isolation (Windows Runtime apps)
Note  Loopback is permitted only for development purposes. Usage by a
Windows Runtime app installed outside of Visual Studio is not
permitted. Further, a Windows Runtime app can use an IP loopback only
as the target address for a client network request. So a Windows
Runtime app that uses a DatagramSocket or StreamSocketListener to
listen on an IP loopback address is prevented from receiving any
incoming packets.
There are several other options depending on what exactly the need is. The most likely two are:
If the goal is only for testing then run the apps on different systems.
If the goal is IPC then implement an App Service. App services are specifically designed for UWP to UWP communication
If you're side-loading (which you'd need to be doing to call checknetisolation anyway) then you can also look into adding a brokered Windows Runtime Component or a desktop app as a broker server which both clients can connect to, but I'd definitely check out the app service option first.

Related

Derby Database Access thorugh a local network LAN

I created a java desktop application with derby client driver using netbeans 8.1.
I used this code to get connected to the database.
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/LibertySchool;create=true;user=liberty;password=liberty");
conn.setSchema("LIBERTY");
Statement s = conn.createStatement();
s.executeQuery("SELECT * FROM USUARIOS");
ResultSet rs = s.getResultSet();
if (rs.next()) {
Login entrar = new Login();
entrar.setVisible(true);
}
The standalone application is working normal on the pc that it was created on after build the dist file has the app.jar file and everything works normal.
I created this so few client computers can access the same application to update data. I have started the derby network on client machine, I have also change the connection from localhost to use the app database location ip server.
But my app does not work on clients on the same network only on the computer where it was built. Other applications that do not use databases works well over the network, it seems that derby database folder has to be moved also to the client machine.
I need to know how to set the client machine properly so users can access the app with the database.
Can someone please give some hints.
If you want to make a client-server connection with the client on a different machine than the server, you'll have to do several things:
Change localhost to a valid externally visible address for the server machine. You can use an IP address, or a host name, e.g., 192.168.1.104:1527 or Carlos-Mac-Pro.att.net:1527, but you're going to need to figure out the right network address to use. localhost:1527 will only work when the client and server are on the same machine.
Ensure that your network allows connections between the client machines and the server machine. Nowadays, most machines will, by default, prevent most inbound network connections from other machines, as a security measure, so you'll need to configure the server machine's firewall, as well as any network devices that are being used in your local network between the client machines and the server machine, to allow TCP/IP connections on port 1527.
I don't think you want to move the derby database folder to the client machines. That would be a completely different architecture for your application (embedded vs client-server). Here's some good background material about the differences between the two configurations: https://db.apache.org/derby/docs/10.13/getstart/cgsquck70629.html

configuring a Windows Server 2012 VM using IIS to call Azure

I'm setting up an ASP.NET MVC5 application on a Windows Server 2012 VM running .Net 4.5 and IIS8. I've always leverages Azure for App and DB services (thank you Azure for your seamless 10 min server setup and publishing solution!) however I need to host this app using this alternative method. The VM is not an Azure VM. I've managed to configure the VM and publish the application (10 hrs of head banging experience... ) however when the application attempts to make a call to the Azure Db during the form registration process I receive a time out error; "The wait operation timed out".
My question is; I can access the application via the ip address from my local machine, I think port 80 is open by default. Do I need to specifically target this port in the applications web.config file for I/O calls?
If you want to connect a non-Azure Virtual machine which is behind a firewall to the resources in Azure, you will have to create a virtual network with either site to site or point to site VPN enabled. Please check this link which explains how to do it. https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-howto-site-to-site-resource-manager-portal/

Connecting to database in asp.net website by Wp8 app

I created localhost website in asp.net in Visual Studio and i added there a MSSQL connection.
My problem is that I created an app for windows phone 8 but i dont know how to connect this app with database which is on this website.
Can you help me with this?
First of all: your Windows Phone app can't connect to a SQL Server database, so you'll have to create an API.
Since you're using ASP.NET, I suggest to have a look at Web API. In short: you'll have several URL endpoints which return json/xml to your Windows Phone app. It's your job to query the database and return a single item/list of items in the controller of that URL endpoint (this sentence will make sense if you read into creating a Web API).
Next task is connecting to this API. Normally you would host it on a public url, so your phone device can connect to it (a phone doesn't know about your pc's localhost). If you want to use localhost with the emulator for testing, you'll have to execute the tasks mentioned in the quote below as this doesn't work out of the box.
When you create a WCF web service in Visual Studio, by default the
service is hosted in IIS Express and only accepts connections at
http://localhost/. Apps that target Windows Phone OS 7.1 can connect
to the development computer as localhost because the Windows Phone 7.1
emulator uses the network connection of the development computer. The
Windows Phone 8 Emulator, however, configures itself as a separate
device on the network. As a result, an app running on the Windows
Phone 8 Emulator can’t connect to the development computer as
localhost. Before you can connect successfully from the emulator to
the local web service, you have to make two changes:
You have to configure the local web service and web server to accept connections from other devices on the network.
You have to configure the service reference in the Windows Phone app to connect to the service by using the IP address of the development
computer on which the service is running.
Source: https://msdn.microsoft.com/en-us/library/windows/apps/jj684580(v=vs.105).aspx

Connect to Local Webservice from Mobile app

I need to make an application where a mobile web app can connect to a local web service in a LAN. For example, several locations are running this web service on their own local server. When someone with the mobile app comes into the location they can open it up and it will somehow be able to connect to that local webservice through WiFi. The mobile app won't know the IP of that webservice ahead of time. Any thought on how to go about this? This will be a .NET webservice and HTML5 app but I don't think that matters.
As mentioned in the comments you will probably have to make it configurable by the user as the will ultimately need the address of the server.
There is however another approach that you can take. Develop a small multicast/udp service that broadcasts the web service address every 10-30 seconds. In your android application register a broadcast receiver that responds to the network connectivity status and runs in the background.
This service on the Android service will pick up the address from the UDP broadcasts and then configure the application.

azure connect between azure myWebRole and nonazure server not working

My webapplication hosted on windows azure, needs to communicate with TFS Server. When any one login to my web app using live id, I want the logged in user to use my Team foundation server(TFS) credentials -username,password and domain to programatically authenticate and connect to our TFS server and create some work items.
I configured my azure connect for the communication to happen between azure WebRole and TFS server (our TFS is non-azure ).I added both the WebRole and the TFS Server into single Connection Group
In my azureportal ,I can see mywebrole and my TFSServer as connected the machine endpoint is active, and that it refreshes since the last connected updates
.But when I try to run my web application from azure and when it tries to communicate with our TFS server ,its throwing error message saying Error message : Team Foundation services are not available from server eg.,http://xyz-abcxyx-01:8080/tfs/eas/. Technical information (for administrator): The remote name could not be resolved: 'xyz-abcxyx-01'
Any suggestions to resolve this issue ?
You should enable remote desktop on your WebRole and connect to one of your instances. Then, try to ping the IP of your TFS server (not the hostname xyz-abcxyx-01). Maybe this is simply a DNS issue (even though using hostnames works with Windows Azure Connect).
If pinging the IP works, but pinging the hostname doesn't work you have a few options left:
Use the IP instead of the hostname. This won't work if you configured your TFS to use host headers.
Create an elevated startup task to modify the hosts file and map the IP to the hostname. In your code you can keep working with the hostname.
Try to modify the DNS server configured in your WebRole to use the default DNS server + your internal DNS server. But to me this doesn't look like a clean solution.
Anyways, in each solution you'll want to store the IP/hostname in the ServiceConfiguration and make sure your code supports changes to the ServiceConfiguration. This will allow you to change the IP/hostname without having to redeploy.
You should check if TFS server is listening on all network interfaces, include the one created by Azure Connect (start with 2a01). Next try to connect to TFS from a machine on the local LAN, just to make sure it is configured correctly. You don't need to use IP for referring to TFS, DNS name is definitely supported out of box.

Resources