Cannot load site on localhost with iOS devices on BrowserStack Automate - ios

I'm hosting a .NET Core HTTP application on localhost using Kestrel on an available port for some browser-based UI tests, but when trying to access it using real iOS devices with BrowserStack Automate with BrowserStackLocal.exe, Safari consistently refuses load the page.
I've tried various parts of the IP ranges documented here, but none have been successful. Desktop browsers (Chrome, IE, Edge and Firefox on Windows, Safari on macOS Mojave) and real Android devices work as expected.
I've also tried using the local IP address of the machine and the fully-qualified domain name (FQDN) as described here, but neither work portably as Windows Firewall blocks the connections even through BrowserStack Automate can resolve the address.
Port 80 is not a viable solution as developers' machines will have IIS running on their machines using that port, so it is not available for other purposes.
Given the following constraints, what are the workable solutions?
Hosted on HTTP.
Runs without admin privileges (i.e. no reconfiguring the firewall or using privileged port numbers <1024).
At least two possible port numbers to use so that if one is in use there's at least one alternate to try.
No additional manual setup required to run the tests (should just be the command dotnet test).

On the iOS devices, try resolving http://bs-local.com:5000 instead of http://localhost:5000.

You can access the site using http://bs-local.com:5000, But make sure to disable the host check for webpack using disableHostCheck: true in configuration.
For angular cli users, to disable to the host check you need to use --disable-host-check like ng serve --port 4200 --disable-host-check

This is from BrowserStack's support:
a) On Safari
Previously, accessing local websites with 'localhost/127.0.0.1' in the URL was not supported on iOS devices running iOS versions 10 and above.
However, to make sure that your website loads with 'localhost' in the URL, we now modify the URL to http://bs-local.com on these devices. This helps in loading your website in an expected manner. The same is mentioned here.
In the screenshot you've shared, you can see the redirection to bs-local.com as well.
It seems that your localhost website is configured to be accessible only via specific hostnames such as 'localhost'. Thus, you face the reported error.
To be able to test your localhost website via Safari on iOS devices, I would recommend configuring your localhost website to be accessible via the private IP address of your local machine.
Once done, you can access your localhost website as http://<private_IP_address:port> and this should work.
I would also encourage reading through this guide to understand how you could achieve the above: https://www.notion.so/Testing-localhost-on-iOS-devices-1ceb5e274cee46d7ac538b71304919b4
b) On Chrome
Due to restrictions imposed by Safari, testing localhost websites on Chrome is not supported by default on iOS devices.
The problem arises with the usage of the domain 'localhost'. We are actively trying to find alternatives for this behavior as well.
However, in the meantime, you can access your localhost website via the private IP address as mentioned above via Chrome browser on iOS devices as well.
Once you make the necessary changes to your configuration to allow your localhost website to be accessible via the private IP address, you can test your localhost website via Chrome on iOS as well.
Feel free to reach out should you need any further assistance!
Note: The private IP address is not the same as 127.0.0.1. You can use this article to identify the private IP address of your machine.
Regards,
Reehan
BrowserStack Support

Did you try changing the 'localhost' with the IP address of the machine (where the web is hosted)?
For instance - If the IP for the machine on which application/webpage is hosted is 22.22.22.22, then change http://localhost:3000/index.html to http://22.22.22.22:3000/index.html in your test
They have mentioned the same here - https://www.browserstack.com/question/663

If you are using Angular CLI then please run command
ng serve --host 0.0.0.0 --port xxxx
This will make sure that you would be able to access application using your IP and port specified. Once done you should be able to access your application using browser stack iPhone device browsers using IP and port rather than localhost.

Related

How to run Grails application so that other computers on network can access it?

I've developed a Grails application and I want my coworkers to be able to test it. They are on my network so I figure they can access it by using my IP address and the port number (8080). I've tried running it according to the steps laid out here and here to no avail.
I noticed that whenever I run the program, even when I follow those instructions, it says:
Grails application running at http://localhost:8080 in environment: development
Basic networking stuff here.
When something starts on interface 127.0.0.1 port something
Usually that port is then available for all the interfaces on the machine
if you run netstat -plant you will see running ports open on the machine.
Basically what ever ipconfig or ifconfig tells under Linux as your internal interface something like 192.168.1.x
The app is then available on http://192.168.1.x:8080
If you can't access it from other machines on network start by trying to ping {your machine ip}
It sounds like network security stopping local access from 1 machine accessing another.
Or even better still your good old MS firewall try stopping your security stuff on your desktop
It's not clear if you can access the app yourself on your own machine? It should be available at:
http://localhost:8080/appname
Your co-workers should be able to access the app by changing localhost to your computer name:
http://mycomputername:8080/appname

How can I access my localhost on my computer from my Android device?

I have a web application written in ASP.NET MVC 5. I simply can open it from the browser with this localhost:14920 in my computer, but I want to access the same application from my Android device's browser while my laptop and Android device are in the same network. I don't know how to access it from Android.
Note: when I type 127.0.0.1 in the Android browser I can access the IIS server, but when I type 127.0.0.1:14920 it prints Bad Request - Invalid Hostname. How can I fix this issue?
You can configure IISExpress for remote access
http://www.ryadel.com/en/iis-express-allow-external-requests-remote-clients-devices/
or just change the hosting to IIS as the earlier commenter mentioned.
Try with replacing 127.0.0.1 with your IPv4 address.
I have used ngrok in the past, when needing to hit my development machine, or have someone else hit it. It is a very useful tool and very simple to install.
Once you download it, it's just a simple command line:
https://ngrok.com/docs#expose
ngrok http 80
(That is for traffic on port 80) Since your port above looks different it would be:
ngrok http 14920
That will give a URL that you can hit or any machine or device.

testing mobile apps at home (IIS hosted)

I am not sure what to look for with the current problem and I appreciate your suggestions.
Basically, all I want to do is locally host a web application on IIS and access it from my mobile browser.
My web application is hosted on the local IIS and works fine on the main machine. I can use my computer name, internal ip or external ip instead of localhost to connect to the app from the main computer. But when I go to another computer (which I can see and exchange files with) connected to the same network I cannot access the web application on the main machine. I tried ip and machine name.
At work, we are connected to a Domain and I tried the same thing with the work computer. When I write my computer name or it's ip, I can access hosted app from another computer.
So the question is, do I have to have a domain for this capability and if so, Is it possible to create a local domain at a home network? What do I need to search for to get this working? Is WAMP a must?
Apparently opening the outbound/inbound port 80 from windows firewall is enough

GWT dev mode ipad

Hi, I'd like to run my gwt project in dev mode and open it on my i pad. How can I do this? I tried to replace the local-host part with my pcs ip address and open the website, but it doesn't work.
If you are using eclipse, the Jetty server binds on the localhost interface only, meaning that it will not serve request when the address is not localhost even if the specified IP is on the same machine. To allow connection from other computers (or iPads) you need to modify this addres in the launch configuration.
Open your launch configuration:
Run --> Run Configurations... --> Web Application --> [YourApplication]
Open the Arguments tab and in the first text box (Program arguments) add the following argument:
-bindAddress [your ip address]
ex: -bindAddress 192.168.1.200
see this post
There is NO WAY to use the dev mode for iOs, because there is no dev-mode plugin for iOS.
You can enable the Super Dev Mode. This will enable a really fast compiler.
update
As mentioned: -bindAddress 0.0.0.0 may be helpful to bind the jetty to any IP.
Your ipad and the system must be connected via Network (LAN).

Remotely viewing web pages served by pow.cx

Using WEBrick you could navigate to an app you were serving from another device/virtual machine by navigating to your.ip.address.here:port
Is it possible to do something similar with pow.cx?
The latest version of Pow (0.4.0) now includes xip.io support. You can read about the release here.
Here's a quick explanation of how this helps Pow serve your Rails apps across your entire local network, from their post:
Say your development computer’s LAN IP address is 10.0.0.1. With the
new version of Pow, you can now access your app at
http://myapp.10.0.0.1.xip.io/. And xip.io supports wildcard DNS, so
any and all subdomains of 10.0.0.1.xip.io resolve too.
Here's a description of xip.io, from their site:
xip.io runs a custom DNS server on the public Internet. When your
computer looks up a xip.io domain, the xip.io DNS server extracts the
IP address from the domain and sends it back in the response.
There are basically two options:
Don't use pow: run your applications on localhost as usual and access them as usual
Edit the hosts file (or local DNS) to point your server machine ip
Example accessing from a virtual windows machine:
Suppose you are running two rails applications in pow: store.dev and auth.dev, and you want to access them from a windows xp virtual machine to test them with IE, you only need to edit your hosts file to add the lines:
C:\WINDOWS\system32\drivers\etc\hosts
# Allow to access applications in pow.
# The ip address points to the host machine localhost, that usually is the default gateway
10.0.2.2 store.dev
10.0.2.2 auth.dev
And then open the IE browser to access your applications in http://store.dev and http://auth.dev respectivelly.
Specifically, no, because Pow uses the Host header of the request to determine which app you need to access. To get that working remotely, you would have to have the remote machine map the required domain name to your IP address - either with a local DNS server or by editing the HOSTS file. Both of which are possible but annoying.
The simplest thing to do in that case is to start up a standalone Rails server as you mentioned (using ./script/server or rails s depending on the version), and then you can address http://[ip address]:3000 as before.
In other words, Pow works because it intercepts your local domain resolution, something that isn't affected by (or available to) remote machines.

Resources