NancyFx - Find the server over a local network - c#

Scenario: I have a small POS system running in a brick-and-mortar store. The software is running in Windows machines with SQL Server 2008 - 2012 (it varies). There are Android tablets that need to connect to the server in someway to get the data inside SQL Server.
My plan right now is to create some REST Web services using NancyFx and host them as a Windows Service inside the Windows machines. Then the Android tablets will need to connect to the server via HTTP in order to consume the REST API.
I have a problem (perhaps more than one): the network in the brick-and-mortar store is not that reliable and the Wi-Fi signal might decrease for whatever reason.
Question: Is there a way to automatically find the IP or machine name of the server (the one with the REST API) even if these properties change for some reason (unknown network issues or so)?
Yes, the server and the tablets are going to be on the same local network.

it's more of a network problem than programming issue. you must have a DHCP server installed in your LAN. use that to assign an IP to the server with a fixed lease. that way you fix the address of server. clients should preferably connect to that server using its name. since it's a Windows network, name would resolve to the ip address.
that is the simplest solution i can think of

Related

Working with System when there is No internet

I have an application that works as a Point of sale(POS). It's designed on angular with mssql as the backend. Now its hosted on a server. It is currently working in a restaurant but sometimes since the restaurant has a makeshift internet, It keeps disconnecting etc. Is there a way to make the thing work without internet. At least just to take the order and then when the internet is one it connects to the cloud and updates the DB.
Depending about what you must do. Yes you can install the server in a local machine and you start your angular in your local machine, but you need to use a local machine server if you use POS to take orders. You can create a private connection with a server and connect all subject to this connect. The customers for pay must be connect to internert.

UWP cannot connect to local Socket.IO server

I have an UWP application which is connecting to a Socket.IO server. When debugging I like it to be a local server, but I can't get it to connect it. I use the SocketIoClientDotNet library, and it works well if I have to connect to an external server, but I can't connect to the local one.
I'm aware that on default UWP apps forbids connecting to local servers, I think it's called loopback, but I'm also tried to go around that by using this tool:
http://loopback.codeplex.com/
However, It didn't helped.
Any help is much appreciated, and thanks in advance! : )
I think the problem is that you didn't enable the relevant capability in your project. Please open the manifest of your app can select the Capabilities label and check the Private Networks (Client & Server) on the left.
This capability's name is "privateNetworkClientServe", this capability provides inbound and outbound access to home and work networks through the firewall.
For more info about capabilities, you can refer to App capability declarations.
Update:
Due to loopback restrictions enforced by network isolation policy, when use TCP protocol, server and client must run on separate machines for them to be able to communicate with each other.

Cannot connect to webservice using the ip address but works with 127.0.0.1

Currently I have webservice using dnx hosted on a specific ip address and connecting to it works fine. The service is listening at port 5004 so inorder to connect to it I use the following format
http://192.X.X.12:5004/api/somePar/?...
Now I moved the webservice to Azure and I use the following address to Remote Desktop onto the virtual machine on which it is hosted.
http://MyLink.cloudapp.net:54254
Now I am attempting to connect to it using its web address.Inside the virtual machine where the weservice is hosted if I type
http://127.0.0.1:5004/api/somePar/?.. (WORKS)
The above works. The ipconfig of the machine gives me say A.B.C.D. If I use that as such it fails.
http://A.B.C.D:5004/api/somePar/?..
I guess that is another reason why my other machines cant connect to the webservice hosted on that machine. Any suggestions on why the ip address of the machine fails and the webservice only works with 127.0.0.1
How can I fix this ?
What OS is the virtual machine running? I had this exact problem with a machine running Windows 7 Professional; apparently, if you're running Windows on that VM, it needs to be Windows Server.
Check the binding, it should specify All Unassigned.
And try changing your port to 80 because 5004 is Real-time Transport Protocol used by Real Time Streaming Protocol (RTSP) for Microsoft Windows Media streaming services and some other things and may be locked.

Connecting to SQL Azure database from client applications

I have a bunch of small desktop applications for which I have a simple database for keeping user data (who uses which app and in which version) etc.
I want the apps to connect to Azure SQL server and update database record when they're started. My apps have the ADO.NET connection string hardcoded in them.
It works fine from my home network and my company guest network - however, the corporate network has got some of the ports disabled, and that apparently includes port 1433. As per Microsoft troubleshooting guide, I tried telnet and failed.
C:\Users\xxx>telnet 65.55.74.144 1433
Connecting To 65.55.74.144...Could not open connection to the host, on port 143
: Connect failed
I cannot connect neither via my applications, nor by SQL Server explorer in Visual Studio.
So, the question is - how can I get around this problem? It is highly doubtful that corporate IT will unlock a port just because I ask, besides I want to keep it as simple, low profile and independent as possible. Or maybe my approach is incorrect from the very beginning and I should do stuff differently?
Cheers
Bartek
You can't.
Make your desktop applications talk to web services instead, over HTTP/HTTPS. Among other things this will also allow a more controlled access (right now anyone can connect to your database and modify the data, since your access credentials are publicly shared with your app).
A side effect of using we services is that 80/443 are almost always opened in all corp firewalls.

monitor local network traffic issue

I am using Networking Tab of Windows Task manager to monitor local network traffic to test how much bandwidth my application will use. My scenario is, I will use a local console client application to send data (using Http POST method) to local IIS 7.0 server.
My issue is no traffic could be monitored using Networking Tab of Windows Task manager. My environment is, VSTS 2008 + C# + .Net 3.5 + Windows Vista x86 Enterprise. Any ideas what is wrong?
Traffic in local loopback scope is not monitored as it don't really use the network. I guess you will have to collect these statistics programatically in your own program, unless you have another machine.
I imagine that as it's all local, I belive Windows will resolve localhost and not forward it to the NIC, thus not producing any network traffic.

Categories