In developing my app I face the following problem:
I need to check if a remote data service (running on IIS) is available from the phone. This requires the phone to be on the same network (same IP range). How do can I check if the phone has wifi, and if the remote server is reachable?
Thanks in advance :)
Related
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
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.
I am trying to set up a shared folder with an old Win CE 5.0 device I am using to learn and improve my C# skills.
Possible options to do this can be done via console: net use sharedfolder \\mypc /user:foo /password:bar, to start an extra process from my C# application which then runs the console with the previous parameters or by using the function WNetAddConnection3.
However, I receive every time Error 53, ERROR_BAD_NETWORK_PATH.
I have checked the connection, as well as the path - always error 53.
A connection between another PC and \\mypc works fine without any problems. By comparison of my PC's network connection with the Win CE 5.0 device I have found out that there is only one difference: the Win CE 5.0 device has one WINS-server less. After setting the IP profile manually (IP Address, Subnet Mask, Default Gateway, DHCP, WINS), as well as adding the missing WINS-server, the problem disappears and the folder has been mounted successfully.
How can I fix this problem without changing the IP profile by hand?
In a normal network the WINS will be set by the DHCP server. The WINS entry of a network connection can also be set manually.
The problem with network sharing on Windows Mobile (WM) and Windows CE (WCE) is that it does not allow IP addresses, it only accepts windows network names. If you do not have WINS, a netbios network name can be resolved by the network card using a hosts entry, a broadcast or a WINS server.
As you do not have access to the DHCP settings of ActiveSync, you can either set WINS manually or by code or simply add a host entry for the connected PC. The activesync connected PC will can act as WINS server or , when you enter the netbios name for the netbios share server, the device can simply translate the netbios name to an IP. So either use the activesynced PC or the netbios server IP address as a WINS entry or add the name and IP of the sharing PC to the WCE/WM hosts table (registry: http://windowsmobilepro.blogspot.de/2006/04/etchosts-file-equivalent-in-windows.html).
[HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts\hello]
"ipaddr"=hex:a1,a3,a5,a9
"ExpireTime"=hex:99,99,99,99,99,99,99
I recommend to use the hosts entry solution and enter the name to use and the IP of the server you want to use.
I have coded a C# MVC Internet Application with Visual Studio 2013 Express for Web on my laptop. I can compile and connect to this application with the following web address in my laptops browser: localhost:22101/
I am wishing to connect to this address in an Android application that I have coded, but am having some trouble connecting to the localhost on my laptop. My laptop is connected with a USB cable.
I have tried the following:
Tried to connect to my laptops IPv4 address from ipconfig
(10.1.1.3)... no connection found.
Tried to connect to 10.0.2.2... no connection found
My laptop and cell phone are both connected to the same wireless router.
Is this possible? Can I please have some help with this?
Thanks in advance
The local development server doesn't respond to external requests.
You will need to run it on a full blown iis I'm afraid.
I have the app for Android and another app for PC, both were written by me. Android app connects to the PC app, and the PC app sends data (in realtime) to the smartphone.
The problem is: if the PC is connected to the mobile wireless network, I can't get its address, so I can't connect my Android app to the PC.
So, is there some simple application (for Windows), that I can use as a server for data forwarding. PC and mobile App will be connected to this server (launched on the station with the static address), and the server will just forward data from one app to another?
Or maybe there are good tutorials for creating such kind of server on C#/Java?
I would use a third pc (a server) that acts as a bridge for Android and PC. I wrote a web service in .NET for a virtual server on the internet. Both Android and PC know the ip address (or the domain name) of the server.
The PC talk to server using .NET native web service call, the Android uses ksoap.
For more infomration about ksoap for android look here:
http://code.google.com/p/ksoap2-android/
EDIT:
I suppose you can have the web server in the pc but you need to configure your modem to forward specific ports to the pc. But if you have no static ip address you need to reconfigure the ip address on Android device everytime your modem is rebooted (or switched off/on). You can also try to use dynamic dns services...
Check this out:
http://whiletrue.blog.com/2013/07/11/smartphone-as-pc-controller/
I've made this with Muzzley. Basically, you already have most of the work done if you integrate with it.
(disclaimer: i work for this project)
On the PC side, you can use the lib to include in you pc app in several languages:
(java) http://www.muzzley.com/documentation/libraries/java.html
(.NET) http://www.muzzley.com/documentation/libraries/dotnet.html
(nodejs) http://www.muzzley.com/documentation/libraries/nodejs.html
On the smartphone side, you can use any of the existent widgets (virtual interfaces):
http://www.muzzley.com/documentation/widgets.html
or eventually make your own:
http://www.muzzley.com/documentation/widgets/webview.html
Example:
You can pull from github several examples here:
https://github.com/muzzley/muzzley-demos/
(check the the webview example)
I hope it helps.