HTTP Adapter not working on real Android device-Mobilefirst platform - http

referring to my previous post.
Using Worklight(MFP) HTTP Adapters with REST/JSON Services
To solve the issue i had to change the value of the host name in the mobilefirst development server from "localhost" to the ip address of my pc so that it works on the android emulator. While installing the .apk file on a real device it does not work. I think when i get the .apk, the ip address i set in the hostname(the ip of my pc) is applied in the
/android/native/assets/wlclient.properties
wlServerProtocol = http
wlServerHost = 192.168.1.2
wlServerPort = 10080
can i have some help please. Thanks.

The IP address that is used by the client application is indeed controlled by the wlclient.properties file.
You can edit this file before building the .apk.
You can also:
Right-click on the MobileFirst application folder -> Run As -> Build Settings
Change the IP address
Build again
From now on, the IP address inside wlclient.properties will be the one you specified above in step 2.

Related

Asp.net - Getting IP Address from devices accessing the local server question

I am developing a web app that uses Asp.net. I found some code that I believe could get ip address of devices. The web app will only run on a network and the devices that are accessing are on the same network. So in other words, the server is local and devices do not need to be accessed through the internet, only on a local intranet.
The code I found is as follows:
string ipAdd = HttpContext.Current.Request.UserHostAddress;
When debugging, I found that the variable ipAdd is set to '::1'. I believe I am getting that value because I am accessing the webserver through the same device. Will I be able to get the device's local IP with that piece of code, if I had a device access the server from another device, say an iPad?
Yes, that has been my experience as well.
Localhost: http://localhost/GK/4.1/Account/AutoLogin.aspx
IP: ::1
Server: http://iis10/GK/Account/AutoLogin.aspx
IP: 192.168.1.70 (my PC's IP. running the app on my IIS 10 VM).
This article by Phil Haack is a little dated; but a good read (re-reading your question, your app will be hosted as an intranet, you might not run into this gotcha): A Gotcha Identifying the User's IP Address
I've used HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") and reading Phil's article he pointed out:
The UserHostAddress property is simply a wrapper around the
REMOTE_ADDR server variable which can be accessed like so.
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]

How to access my localhost website from my phone?

Good day to all,
I am trying to create my website locally, and perhaps access the website through my phone from the localhost. Forgive me I am just a beginner.
So I used ipconfig -all to find my IPV4 address and it was e.g
192.168.1.102
And on the ASP.net webapplication I ran, the address was:
https://localhost:44337
Hence, I was trying to access this Web Application of mine created on my PC, to be accessed on my phone. On my phone, I entered the address:
192.168.1.102:44337
I went into my firewall setting to add a new rule for inbound connection to allow all ports to be connected as well. But it still don't work. Both my PC and phone is connected to the same wifi.
Does anyone know the fix? Thank you in advance.
You might have to configure an IIS server. This tool comes default in Windows (professional?), and there's lots of good resources on how to do this, all of which do a better job of explaining the process than I could do.
Essentially, you will need to:
Publish your site (Done through visual studio or cli)
Enable and configure your IIS
Create a new website in the IIS manager and point it towards the output of your web app publish
After opening the neccessary firewall ports, check to see in which IP address your web application is running. I am assuming you are using some sort of HTTP webserver software like IIS(windows) or Apache(Linux). In IIS to do that you must go to your site bindings and where it says "IP Address", select "All Unassigned" (NOT localhost or 127.0.0.1)so that the web application runs in all network adapters and IP addresses.
See full IIS documentation here: https://learn.microsoft.com/en-us/iis/get-started/getting-started-with-iis/getting-started-with-the-iis-manager-in-iis-7-and-iis-8
Follow the guide: https://medium.com/#manujsdeveloper/debug-a-website-local-or-remote-hosted-on-an-android-mobile-device-ff2c43527be1
You will need to set your phone in developer mode and get the OEM USB driver specific for your phone. and get a ADB running on your computer
I suggest supplement your knowledge with with links below, as some things are left out in the above guide and vice versa:
https://developer.android.com/studio/command-line/adb
https://developers.google.com/web/tools/chrome-devtools/remote-debugging

use local machine IP address to test website on local machine

Hi i am developing a website and want to test it on local machine
the flow is like this:
A -- my website
B -- third-party website
From A a request is sent to B with a url eg: http://mywebsite/abc.aspx which is a url on which B reports success or error.
so i need to define the url to report to
for this i need to give a absolute url or path.
thats why i cannot test it on local machine and have to upload it and test it.
but this doesn't allows me to track down errors and debug it.(through break points.)
so i am trying to get the local machine address like "http://123.456.7.8/abc.aspx"
but doesn't seems to work.
my pc is running on windows xp and is connected to router and my pc is in a network and i think that's why gets a dynamic IP.
have also tried public ip address but no luck.
any work around or help for this.
I believe you're trying to get an external website to contact your local PC. Your local PC is behind a router and getting a private IP from your local router.
You'll need to supply the external website with an address that has the external IP of your router and configure your router to forward incoming requests to yuor PC.
i.e. to forward port 80 on the router to port 80 on your XP machine.
Thus when the external website, tries the contact http://1.2.3.4/abc.aspx it will talk to your router, that will then pass ("forward") the request onto your PC at e.g. http://192.168.0.1/abc.aspx.
I believe You can try to use your Machine name.
You can set up a local DNS server or simply utilize hosts file, to cheat your web browsers. For example, register test.com to your machine's IP address, and then you can use http://test.com to access IIS default web site (or your web site on IIS if you configure it for the default URL).
http://en.wikipedia.org/wiki/Hosts_%28file%29
This is a typical approach to test out web application locally.
try hosting your website on IIS and then give fix IP to your system and try to access it with your IP. Another thing is get your global IP (you can check it from Whatismyip.com ) and set it in your binding in IIS for getting request to it from across the internet.

Remote debugging ASP.NET applications on a server with static IP address

All of examples on web assume the remote server which we are going to debug remotely is on the same network. I have only a static IP address and using RDP I connect to server.
I've installed Remote Debugger on remote machine but cannot set the static IP address as Qualifier in visual studio -> debug -> attach to process
The username#machinename construct displayed in msvsmon is the text that needs to go into the Qualifier box in Visual Studio -> Attach to Process.
For example, where msvsmon says:
msvsmon started a new server named 'tf#macmini'. Waiting for new connections.
you would type tf#macmini into the qualifier box.
For a machine out on the internet, I'd guess you use username#[ip address here], e.g.
tf#123.234.32.1
Though you will need to make sure, at a minimum, firewalls and authentication are set up correctly. (The debugging will not occur via RDP.) There's an article on the firewall side of this here. Can't remember off the top what the authentication involves, although I suspect as a minimum you will need an account on both machines with the same username and password.

Cannot access web application (Internet Explorer Can Not find this Page) remotely

I have Deployed my Asp.net web application on IIS 7.0 on localMachine(Server) and it is working fine there.
But when i try to access it from other machine in LAN, It gives me error that, 'Internet Explorer Can Not find this Page.'
I am accessing it on terminals using server name address and also tried using IP address.
Even I have Shared the Application Folder in network.
Check the Windows Firewall on your Vista PC. You need to let TCP port 80 through.
Make sure that you enable the firewall and bind to IP addresses other than localhost.
You don't need to and should not share the application folder.
This is a security risk as people on the network will be able to access the source code of the application. Also, it won't help with the problems you're having because a network share is not accessed over HTTP and so will never hit IIS and your web application. So you can turn off sharing for the folder and be safe in the knowledge that this isn't the issue.
Next, check your windows firewall and make sure incomming web trafic is allowed ("http" or "port 80").
Next I would have a look at the host headers that the site is running on.
Then maybe update your question with more detail.
Greg
You may also want to ensure that IIS is listening on the correct IP Address. This problem can occur if you switch from a LAN connection to a wireless connection (for example when taking a work laptop home).
To Check this, open inetmgr and right-click on the 'Default Web Site' node. Verify that the IP Address entry is set to the current IP of your machine.

Resources