Connecting to localhost:8080 using Google Chrome - javascript

I'm currently developing a card game using node.js and gulp, and suddendly Chrome stopped to find localhost:8080. After some research, some people had the same problem and solved it by disabling "Built-in Asynchronous DNS" in chrome://flags, however, this flag seems not to exist anymore.
When a friend of mine launch the same code also with gulp and with the same version of Chrome, it works. Any idea ?

In the chrome url bar type "chrome://net-internals/#hsts"
and delete the localhost domain, by typing "localhost" into the Delete Domain text box.
Type "localhost" into the Query Domain text box and if it says "Not found" than it was successful.

I was running into this issue as well. None of the other answers worked for me.
What did work for me was simply changing the port of my localhost to 3000.
Using Webpack:
// webpack.config.js
module.exports = {
...
devServer: {
port: 3000,
},
...
};

I am not very experienced in web developing and this might not be a very good answer. I am new to stackoverflow, so I cannot add any comments. That is why I post this as an answer to share my experiences.
One possible scenario is that you are already running an application that uses port 8080. As an example, if I use WAMP server to host a web page in port 8080 and Node.js to run a REST API in port 8080, one application might run on localhost:8080 and other on 127.0.0.1:8080 even though they are the same and the webpage will not be able to use the REST API because the hosts do not match. In fact, this happened to me while ago and I could not find a solution for it. So I had to serve the web page through Node.js. Hope this answer is helpful.

You should see the /etc/hosts file to find out the DNS pointing and secondly use 127.0.0.1 should point to your hostname or default server for the local host to work.
The DNS can't find anything running your localhost:8080, because either something else is running there or you simply didn't tell your localhost i.e. 127.0.0.1 to point towards your server.

Related

Error from p5.sound in browser when it is hosted via HTTP?

I use p5.js in my school project and it does not work in Google Chrome(also Microsoft Edge, idk about Opera), with JavaScript activated, but only when its on hosting. When I got it on Localhost it works just fine. In Mozilla it works in both situations. Iam confused.
http://klauzury2c2021.8u.cz/
you can find all of the code on the site
It looks like you are are hitting this issue with the p5.Sound library that prevents it from working correctly when loaded over http. Since you're hosting your site on a public server the best solution would be to enable HTTPS for your server and have HTTP requests redirect to the HTTPS url. However if you are unable to do this you can make this work with an AudioWorklet polyfill. Just add the following line to the head of your html file:
<script src="https://unpkg.com/#free-side/audioworklet-polyfill/dist/audioworklet-polyfill.js" type="text/javascript"></script>
Updated ↑ Old Answer ↓
I originally misread your question and though you were specifically struggling with testing on localhost. Here are instructions for cases where you are testing with a local server:
Apparently people have had success working around the issue using a tool called ngrok. Which allows you to expose a local service via a public HTTPS endpoint. So if you're running a local HTTP server on port 3000 you would open a terminal and run ngrok http 3000 (having followed the basic installation and setup steps for ngrok). Nrok will assign you a public URL, which it will display in a message to the terminal like this:
Forwarding https://<UNIQUE_ID_HERE>.ngrok.io -> http://localhost:3000
Then instead of accessing your sketch page via http://localhost:3000/ you can access it via https://<UNIQUE_ID_HERE>.ngrok.io/ and that should work around this p5.sound issue.

Why do i get a "404 not found" error on IE(not Chrome) in node.js express? and how to solve?

I'm making web server with node.js and express module.
So, I installed node.js, express and express-generator.
And I completed a prototype web server for my project yesterday.
But, when I tested my prototype, I have a strong question.
In Chrome, I could connect for URL like '127.0.0.1:3000'
or '172.30.5.164:3000'(this is my intranet ip address).
But!!
In Explorer, I could't connect!!
So, I tried to find the way.
I solved the 127.0.0.1:3000 problem.
Just I changed Explorer configuration for intranet and I could connect
like this way 'http://localhost:3000'
However,
I didn't find the way how to connect use URL like http://172.30.5.164:3000
I don't use socket.io module, just use basic express-generator template like GET/POST way.
I need how to connect on IE strongly because my project is related to OLE Automation, So I have to use ActiveXObject.
Anyone who give me the hint?
I'm not good at english writing, so i got to worry about that you understand my problem.
Thanks in advance.
There is a strange way IE handles local ip
see article.

Embedded Devices - Javascript Debugging

I work on embedded devices but am not able to install any software on them (e.g. programs like gdbserver are out). I need to monitor javascript events on those browsers. For example, if we run a web app on the EWB, the device it's on might have a keyboard pop-up. I need a way to see what triggers this event.
I am thinking along the lines of perhaps embedding something into the HTML or javascript that automatically reports any events back to a workstation somewhere.(I already have logs, but they are not live and it's difficult to pinpoint what happens - even beartailing them... wish I could have something like Firebug, but since it's embedded I can't)
Has anyone seen anything along those lines?
To get a debug connection to a web app or page running on a remote device:
Install vorlon using npm
Download ngrok
Start the vorlon server, the server port will probably be localhost:1337 and the following steps assume this
From a terminal/command prompt run ngrok with ngrok http 1337 and it should report an ip address for the other end of the tunnel, something like def01234.ngrok.io available via http and https.
Instead of the local script tag which vorlon suggests, use the remote ngrok address, e.g. <script src="https://def01234.ngrok.io/vorlon.js"></script>. ngrok exposes both http and https - as this is over the public internet I would strongly recommend using a secure connection.
Log onto the vorlon server on your local machine.
If the above test works you are going to want to do two more things:
Get an account at ngrok (or an alternative secure tunnel service) to get a fixed address.
Configure vorlon authentification according to the instructions on this page. By default it is insecure so ANYBODY with the exposed ngrok address could log onto the dashboard and mess with your embedded devices.

Casperjs/Phantomjs does not respect hosts file

I am trying to run tests against my vagrant box with lives at 192.168.0.100. In my hosts file I have 192.168.0.100 lc.mysite.com and the site loads fine and works normally at that url with chrome.
However, when I try and run my tests against it, the url fails and never loads anything. Remote urls work fine but the local ones are just failing.
How can I get casperjs to respect my hosts file? Or is it something else?
If you are using a self-signed SSL certificate (e.g. on your development box), set phantomjs option
--ignore-ssl-errors=true
From the documentation:
--ignore-ssl-errors Ignores SSL errors (expired/self-signed certificate errors): 'true' or 'false' (default)
Turns out it was due to the url being ssl and it kept failing. Using this answer solved my issue.
CasperJS/PhantomJS failing SSL handshakes on some sites even with --ssl-protocol=any

How to open an HTML project on the iPad

I have an HTML project (CSS/JS/jQuery) that I'd like to test on an iPad (in Safari). From what I've read, iOS browsers don't support the file:///path/to/project protocol, and even if it did, I don't believe that you'd be able to navigate the file system to where your project is located.
Please correct me on any of this information if I'm wrong, I'm an Android guy so much of this is new to me. Nonetheless, I tried to use an app called Fileapp to solve my problem. I was able to access and load my project, but it was within Fileapp's native browser, and not Safari (unless it actually WAS Safari and it was just masked).
Does anybody know of a solution to my problem (preferably free)?
2016 UPDATE:
There are several services which now make this easy. If you don't have your own web server check out one of these free services which make updating a live webpage from your PC easy:
Heroku
Git Pages
Both of these services require using git, learn it, you won't regret it.
Days of FTPing or using Dropbox to serve html to an iPad are long gone.
If you need to be able to do this while not connected to the internet check out this article on using local IP tunneling. This would essentially open up the localhost on your PC to be viewed by anyone on a wifi network, regardless of if the wifi was actually connected to the Internet.
http://wesbos.com/localhost-mobile-device-testing/
I prefer Heroku as I am more likely to be switching between locations and PC's than I am to be on a wifi network without an Internet connection.
OLD ANSWER 2012
Get a Dropbox account and put the project in your public folder.
Right click to get the public link and then browse to that location on your iPad.
When I get link from the iPad app it doesn't work it just shows the raw html with a URL structure like so
dropbox.com/s/...
When I go to the website and copy public link (only available if the file is in PUBLIC FOLDER) I get the link that actually works.
Apache probably isn't the most convenient webserver to use for this kind of ad-hoc serving of a local project. Instead, if you're on Mac or on a Linux distribution that has Python installed (which is most of them), you can launch a webserver to serve your current working directory at the terminal with a one-liner:
python -m SimpleHTTPServer
By default it will serve on port 8000; you can specify another port by passing it as a final argument to the command.
To connect to this server from another device, like your iPad or phone, first of all you'll need to make sure your phone is connected to the same local network as your Mac or Linux PC. Then, on the computer, run
ifconfig
and look through the output for your local IP address, which will be labelled as inet addr in the output and listed under one of the connections other than "Local Loopback". On my current PC, I see inet addr:192.168.0.3 listed under the wlan0 connection.
Now, on your phone, open your browser of choice and navigate to the IP address you got from ifconfig on whatever port SimpleHTTPServer is serving on. For example, http://192.168.0.3:8000. You'll be presented with a directory listing corresponding to the directory in which you launched the server, and from there you can view whatever files you're interested in.
The answer to your question is that even with iPadOS the iPad is not a replacement for a Windows, Linux, or Mac. Still too many “can’t get there from here” cases.
One solution to the problem, as pointed out by minitech in the comments of the original questions, was to set up an apache server on my local network and connect directly to it. This worked exactly as I needed it to.

Categories

Resources