Bluemix Spring - Application must be listening on the right port - angularjs

I'm trying to deploy a Jhipster application (Spring Boot + AngularJS) to Bluemix Tomcat. However I always get this error:
Error restarting application: Start app timeout
TIP: The application must be listening on the right port. Instead of hard coding the port, use the $PORT environment variable.
The complete error on Bluemix console is:
App instance exited with guid 1c76324f-57fb-4a00-b203-499519b4367c payload:
{
"cc_partition"=>"default",
"droplet"=>"1c76324f-57fb-4a00-b203-499519b4367c",
"version"=>"0103e173-b6d3-4daa-a291-b5792c16b69b",
"instance"=>"0c09506c30764b6c921cabb9a55d9e45",
"index"=>0,
"reason"=>"CRASHED",
"exit_status"=>255,
"exit_description"=>"failed to accept connections within health check timeout",
"crash_timestamp"=>1479341938
}
Instance (index 0) failed to start accepting connections
I've already tried to change the application-dev.yml config to
server:
port: ${VCAP_APP_PORT}
Or
server:
port: 80
However, I have not had any success. How can I pass the port variable to the Jhipster configuration?

Related

ASP.NET Core 6 Server running on different ports

I'm getting a proxy error
Proxy error: Could not proxy request /api/auth/signin from localhost:51171 to http://localhost:3000/
I have noticed that on the starting the server is running on two different ports...
info: Microsoft.AspNetCore.SpaServices[0]
Starting create-react-app server on port 51171...
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
In the package.json I defined the proxy as follows:
"proxy": "http://localhost:3000"
Changed proxy to: "proxy": "http://localhost:5000" and now its working...
Still dont know why smth is running on 51171

JEE application in Docker accessing local DB port

I am trying to deploy a JEE application in Docker container. The application requires embedded apache derby on port 1527. It works fine when run in regular dev environment. However, when I run inside a Docker container, the connection on port 1527 is refused.
Things to note, I am using 'default' db connection. That means the application is trying to access the database on localhost:1527. Following is the error message:
java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused (Connection refused).
I am wondering what does localhost mean within a Docker container, the host server or the container?
Any suggestions to fix it?

Pushing app to bluemix

I am trying to push my angular express web app to bluemix, but I am getting this error
2016-04-05T20:12:50.96-0300 [App/0] OUT > angular-expess-seed-
with-html#0.0.1 start /home/vcap/app
2016-04-05T20:12:50.96-0300 [App/0] OUT > node app.js
2016-04-05T20:12:51.19-0300 [App/0] OUT Express server listening
on port 3000 in production mode
2016-04-05T20:13:50.37-0300 [DEA/34] ERR Instance (index 0) failed
to start accepting connections
2016-04-05T20:13:50.39-0300 [API/2] OUT App instance exited with
guid b3554c4b-11f5-433f-891e-1df16605df80 payload:
{"cc_partition"=>"default", "droplet"=>"b3554c4b-11f5-433f-891e-
1df16605df80", "version"=>"36d8b569-d38a-465d-8bc6-b14ffd13b413",
"instance"=>"dbd3566e0ef348d9b9f483a32e8fed89", "index"=>0,
"reason"=>"CRASHED", "exit_status"=>-1, "exit_description"=>"failed to
accept connections within health check timeout",
"crash_timestamp"=>1459898030}
2016-04-05T20:13:50.40-0300 [App/0] ERR
2016-04-05T20:14:16.36-0300 [DEA/24] OUT Starting app instance
(index 0) with guid b3554c4b-11f5-433f-891e-1df16605df80
First it was complaining about the start script missing I've fixed that part but no such with this error.
I can see from the error below:
Express server listening
on port 3000 in production mode
that your Node.js application is trying to listen in port 3000. That works in local environment, but for Bluemix you have to get the port from the Cloud Foundry (CF) environment.
Here is a sample code to do that:
// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
var cfenv = require('cfenv');
// get the app environment from Cloud Foundry
var appEnv = cfenv.getAppEnv();
// start server on the specified port and binding host
app.listen(appEnv.port, '0.0.0.0', function() {
// print a message when the server starts listening
console.log("server starting on " + appEnv.url);
});

Connecting a secured websocket on Google Appengine frontend with managed VM with nodejs runtime

I've trouble in connecting to a wss secured socket server via google appengine frontend with managed VM support.
buy default google exposes only port 8080 in docker image google/nodejs-runtime, Even if expose port 8443 in Dockerfile like below i can connect only to http://localhost:8080 not https://localhost:8443
FROM google/nodejs
WORKDIR /app
ADD package.json /app/
RUN npm install
ADD . /app
EXPOSE 8443
CMD []
ENTRYPOINT ["/nodejs/bin/npm", "start"]
Still i can see port 8080 include in the container
"/nodejs/bin/npm start 8443/tcp, 0.0.0.0:8080->8080/tcp
If i log in to my managed vm instance and run the container image with
docker run -d -p 8443:8443 nodejs.default.wss-check:latest
and try
$curl https://localhost:8443
I get curl: (60) SSL certificate problem: unable to get local issuer certificate, It looks like its connecting but i've to use realdomain name
I've created a issue in github aswell https://github.com/GoogleCloudPlatform/appengine-nodejs-quickstart/issues/13, but not that helpful.
Same set up works like a charm in normal compute instance. but it doesn't auto scale.
Any help on this issue will be appreciated.
The reason you can't curl to https on localhost (curl: (60) SSL certificate problem: unable to get local issuer certificate) is because "localhost" is unknown to any CA. You need to run curl -k https://localhost:8443 to get it to ignore the lack of a certificate for localhost.
Looks like currently Google Managed VM supports Websocket connection only on JAVA
Even if you try websocket connection on with nodejs on GMV it defaults to polling transport. if you wanna see this in live you can use set socket transports, deploy to live and look in to console- network and see which transport its using!
socket.set('transports', [
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]);
We have to wait untill google implements websocket support in Managed VM. If anyone get this working on GMV, Please comment here :)

App Engine Go SDK web server running in Vagrant guest (with port forwarding) not reachable from host

I'm running GAE dev server within a Vagrant guest precise64 box with the following network setup (in my Vagrantfile):
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.network :forwarded_port, guest: 8080, host: 9090
end
Which does its thing:
[default] Forwarding ports...
[default] -- 8080 => 9090 (adapter 1)
I start my App Engine server with:
goapp serve
or
dev_appserver.py myappfolder
This starts app engine dev server as expected:
INFO 2013-11-22 dispatcher.py] Starting module running at: http://localhost:8080
In all cases, I'm able to ssh in to the Vagrant guest and curl localhost:8080 successfully.
Unfortunately, from the host I'm unable to get a response from localhost:9090 when running GAE dev web server. Additionally, I've made sure that I don't have anything interfering with the port 9090 on the host machine. Also, I'm almost positive this isn't related to Vagrant as I spun up a quick node.js web server on 8080 and was able to reach it from the host. What am I missing?!!!
You must run the Google App Engine Go dev web server on 0.0.0.0 when leveraging Vagrant port forwarding. Like so:
goapp serve -host=0.0.0.0
See the answers here for more info on ensuring the guest web server is not bound to 127.0.0.1 which is loopback. Web servers that bind to 127.0.0.1 (like App Engine Go dev web server does) by default should be overridden to use 0.0.0.0.

Resources