Application generated with JHipster 4 returning blank page on 8080, but not on 9000 - jhipster

I've create an application with JHipster v4. When I make a request on port 8080 it is returning a blank page. If I use yarn start, and I make a request to 9000 port, it is answering correctly.
Any idea?

I had the same issue with JHipster application bringing up the blank page on port 8080 when ran with ./mvnw in dev mode. I was able to resolve this by running:
yarn install && yarn webpack:build
After it finishes, the application shows normally in dev mode on port 8080.

I had the same issue where on port 8080, it was returning nothing and on 9000 it gave correct page , after
yarn install && yarn webpack:build
I get correct page on both, I noticed that if I only run .mvnw, the application runs fine and I do not need to run "yarn start"

By default, yarn listens on port 9000 (webpack + browser sync) to hot reload frontend code and contents, maven or gradle listens on port 8080 to hot reload server code. You must run both in dev.
If you start making changes to the client side code without having yarn start running, nothing will be reflected as the changes are not compiled so you need to either run yarn webpack:build manually after changes or have yarn start running.
It's written in the README.md of the project you generated and is documented on JHipster web site.

You should run npm install then mvnw, and it will run good.

For me (using npm for the front-end), just running npm start before mvnw makes the front-end available on 8080.
On the other hand, running npm start after mvnw will bring a blank page on 8080.

Related

Is this dockerfile set correctly to serve a React.js build on port 5000?

I have a React.js app which I have dockerized and it was working fine until yesterday when there was some kind of an error which I found out is due to node version 17 so I decided to get the docker image's node version back to 16. All good, but since I did this, I cannot get the docker image to run on the specified port.
Here is my dockerfile:
ROM node:16.10-alpine as build
RUN mkdir /app
WORKDIR /app
COPY /front-end/dashboard/package.json /app
RUN npm install
COPY ./front-end/dashboard /app
RUN npm run build
# Install `serve` to run the application.
RUN npm install -g serve
# Set the command to start the node server.
CMD serve -s -n build
# Tell Docker about the port we'll run on.
EXPOSE 5000
As you can see, I am making a build which I then serve on port 5000 but for some reason that does not work anymore and it used to work fine.
All I can see as an output in docker is:
Serving! │
│ │
│ - Local: http://localhost:3000 │
│ - On Your Network: http://172.17.0.2:3000
When I go to localhost:3000 nothing happens which is fine but it should be working on port 5000 and it does not run there. Any idea why I cannot run the docker image's build on port 5000 as I used to do before?
I use docker run -p 5000:5000 to run it on port 5000 but this does not solve the problem.
I faced issues at work due to this exact same scenario. After a few hours of looking through our companies deployment pipeline, I discovered the culprit...
The serve package.
They changed the default port from 5000 to 3000.
Source: serve github releases
So, to fix your issue, I recommend to add -l 5000 in your serve cmd.
From the logs you can see that your application might be listening for traffic on localhost:3000. Your EXPOSE 5000 line does not change that behaviour but makes Docker (and other users) think port 5000 is important. Since nothing is listening on port 3000 obviously you should get a 'connection refused'. You may want to lookup https://docs.docker.com/engine/reference/builder/#expose
To get out of that situation:
ensure your dockerized process is listening to 0.0.0.0:5000. You will have to add -l tcp://0.0.0.0:5000to your CMD line (see https://github.com/vercel/serve/blob/main/bin/serve.js#L117)
When running the container, ensure you expose the port by using docker run -p 5000:5000 ...
If need be tell your docker host's firewall to allow traffic to <ip>:5000
Now if you connect to http://<ip>:5000 you should see the application's response.
Your app is listening on port 3000. So you need to map whatever port you want to use on the host to port 3000. If you want to use port 5000, you should use -p 5000:3000. Then you should be able to access it using localhost:5000 on the host machine.
You should think of containers as separate machines from the host. So when the container says that it's listening on localhost:3000, that means localhost in the context of the container. Not the host.

How do I run this aframe boilerplate code locally with https instead of http?

I'm a newbie so sorry if this is a stupid question.
I was trying to setup this a-frame boilerplate code.
https://github.com/aframevr/aframe-boilerplate
This is the instructions given.
To serve the site from a simple Node development server:
npm start Then launch the site from your favourite browser:
http://localhost:3000/
This works as expected, but the webcam is restricted because the site is http and not https. I want to know how to serve this as https instead?
Furthermore I am confused on what actually happens when you do npm start.
The start script is budo --live --verbose --port 3000 --open.
But the project doesn't have any js files that could be the server. Only the html file in the front end. What actually happens with npm start?
npm start runs:
"start": "budo --live --verbose --port 3000 --open",
running budo starts the server
--live enables LiveReload on HTML/CSS/JS file changes
--verbose enables debug messages
--port defines the port
--open launches the browser once connected
by default it uses index.html which is in the main directory
If you want to create a https server instead of http you need to add one more option:
--ssl, -S create an HTTPS server instead of HTTP
If you see some unknown commands run, always try to find the documentation and search the keywords (like HTTPS).

Ember Server: "Port 4200 is already in use", when no process runs on 4200

When running my ember application with ember serve -e local I get:
Port 4200 is already in use.
Which is weird because no application is running on 4200. I tried to open a dummy HTTP server on 4200 with http-server and it works just fine. It also works when I specify the port via a command line flag ember serve --port 4200.
Some things I've tried:
Restarted my computer.
Removed the node_modules.
Remove the ember tmp directory.
Disabled my firewall.
Tried with disabled wi-fi.
Any thoughts?
I'm running on masOS High Sierra 10.13.6 with the following versions:
node: 8.11.3
ember-cli: 2.18.2
npm: 5.6.0 (also tried with 6.3.0)
Also useful to know:
I have other ember applications running on my computer just fine.
I started to have this problem only recently.
In the past, macOS would keep asking me about authorizing incoming traffic whenever an app was opened, but now it stopped asking me.
I had this issue and tracked it down to using a string vs. integer for port in .ember-cli.
// .ember-cli
{
"port": 8080, // works
"port": "8080", // throws the error mentioned above
}
Not sure if this is the cause for others with this error. As mentioned, first thing is to make sure nothing else is actually running on that port. But OP had already checked that, and so had I.
After further investigation, it seems that the problem is not coming from macOS, but from something messed up in the dependencies causing ember-cli to fail...
It's not quite clear what is causing this, and I will try to post any additional information here, but for now if you happen to encounter this problem, just pass the port value directly to ember-cli like so:
ember serve --port 4200

Node web server not visible externally, but Python is (MacOS)

I'm just starting to build an Ionic 2 app, but I can't get it working on my mobile device.
Python (works)
To demonstrate that the phone can see the host, I tried a Python server:
$ python -m SimpleHTTPServer 8000
Serving HTTP on 0.0.0.0 port 8000 ...
If I go to http://192.168.8.101:8000 on my phone, it connects fine and displays the directory listing.
Node (fails)
However, when I start Ionic:
$ ionic serve -p 8000
[...]
[INFO] Development server running
Local: http://localhost:8000
External: http://192.168.8.101:8000
I can load it in my host's web browser, but I can't see it from my phone nor another computer (it times out). I also tried a basic node server:
$ npm install http-server -g
$ http-server -p 8000
Starting up http-server, serving ./
Available on:
http://127.0.0.1:8000
http://192.168.8.101:8000
With the same result as Ionic: accessible from the host, but not from the phone.
Is there something blocking the request? Or is there some Node configuration I'm missing? I'm new to both Mac OS and Node, so I don't know where to look.
Embarrasingly, this turned out to be a firewall issue. In System Preferences > Security & Privacy > Firewall > Firewall Options, Node was explicitly set to deny incoming connections:
Changing it to Allow has fixed it. Phew!
Just execute ionic address and you'll get an IP address in your command line. Try with that ipaddress:port number from your mobile which will enable you to access your site from your phone.
Just incase if the ionic address command doesn't return anything, you need to execute the below command to point it to your ip,
ionic serve --address YOUR_IP_ADDRESS
Hope this helps!

Debugging Kibana backend Node.js code

How to debug Kibana backend source code?
I presume, node-inspector could be used. And some extra configuration needed for package.json file to run debugger at npm start. But, I can't figure out the correct configuration syntax.
NODE_OPTIONS=--debug bin/kibana --dev
If you want to break before starting:
NODE_OPTIONS="--debug --debug-brk" bin/kibana --dev
Alternatively, you can set the same variable when calling npm start:
NODE_OPTIONS=--debug npm start
You will see:
Debugger listening on port 5858
You can then use the node inspector by running node-inspector and opening http://127.0.0.1:8080/debug?port=5858.
If you are debugging a remote server, you can either run node-inspector on the server and forward port 8080 through SSH, or you can run node-inspector locally and forward port 5858 through SSH.
EDIT: As it was now mentioned in the comments, it might be necessary to edit the source and add debugger; at the beginning, otherwise breakpoints might not work correctly even when using --debug-brk. Not sure why, though.
add $NODE_OPTIONS --no-warnings --inspect
and start kibana server and access the link shown in the logs like this link "chrome-devtools://devtools/remote/serve_file/#521e5b7e2b7cc66b4006a8a54cb9c4e57494a5ef/inspector.html?experiments=true&v8only=true&ws=localhost:5858/node" then you will find your backend code in the source tab and you can debug it like debuging frontend code.

Resources