Pivotal Cloud Foundry - Deployed Spring Boot App failed to run because of java netsocket(port) permission denied - spring-boot

so, i tried to deploy spring boot app to a PCF Server. When i deployed it, the logs showed that my application was shut down because it failed to open a tomcat server because there is a java.netsocketexception where it says that permission denied. The tomcat server was fine for a moment (it successfully use the port) but the next moment, it was shut down because there is the permission denied netsocketexception.
the port i tried to use is port 443. i tried to look up to several kinds of problems. one of it said that i need to have root access to be able to use port lower than 1000. the problem is, my other apps, which is eureka server run perfectly even when i use port 443.
the configuration, build-pack, and everything is the same. and it is even deployed on a same pcf platform. so, why can this app failed but the other (eureka server) can use the 443 port.
can anyone tell me for the things i need to check to make sure of the problem?

Remove server.port configuration from Spring Boot yml / properties configuration. It will by default expose the service to 443 on PCF

Related

Is there any specific port for https redirection in Spring Boot embedded tomcat?

I already have a tomcat server running in a VM with port as 443 and redirect port as 8443. Can I configure the redirect port for spring boot application also as 8443 and run in same VM? Would I face error like port already in use? If yes, are there any specific port to be used for this purpose? I would not like to try since this is a production environment VM.
By default the https port used is 9393 in springboot.So , in your application if you need it to be 8443 , you need to configure it in the application.properties or application.yml like
application.yml
server:
port: 8443
or
application.properties
server.port=8443
Yes, you will have issues if some other application is using the same https port on the same VM, you will have to find a port that is not used by any other application and assign it for your springboot application. Check in your vm if any other application is already mapped to this port, if not you can use this port without any issues.
Please note that :
If HTTPS is enabled, it will completely replace HTTP as the protocol
over which the REST endpoints and the Data Flow Dashboard interact.
Plain HTTP requests will fail - therefore, make sure that you
configure your Shell accordingly.
Spring doc.

how to deploy springboot app in windows server 2012?

I'm developing a SpringBoot app and I need to deploy it on a remote server running Windows Server 2012. I tried running the app from eclipse there, and i can access locally from the server, but when I try to access from other devide using the IP of the server it has no response. Any idea about how can I deploy it? The app runs on port 8080, so the URL is locally: localhost:8080/start/
but when i access XXX.XXX.XXX.XXX:8080/access/ there is no answer
I beg you to help me, I'm desperate
When you run your application in eclipse , the tomcat might be configured to listen to localhost, but still if your remote is in the same network as your local system you should be able to access the endpoints without fail.Make sure that the remote is open to the public , otherwise it won't be accessible to other devices.
If you are using spring-boot to create an executable war or jar to be deployed to a remote server for long term , you can use the Windows service wrapper provided by springboot itself to register your application as a service in windows.
Please read the doc and the sample code to implement it.
You may have to enable CORS--- #CrossOrigin on top of your controller class where you have you #RestController annotation

AWS EC2 - not able to trigger spring boot webservice from outside but running fine in local host

I am running a spring boot web app for restful sevices in ec2 windows. It is working fine local host. I am using port 8083. But not able to trigger s3rvices from outside.
I have opened port 8083 in security group as TCP.
Plz help..What could be issue.
Same EC2 has .Net web application running and it is working fine and able to access from outside.
Ensure that 8083 port is open for inbound and outbound properties in security groups of ec2 instance.
Refer this to do the same.
How to open a web server port on EC2 instance

CF Spring boot app failed to start accepting connections

I have developed a Spring boot application connecting to Postgresql instance running on my local.
Now i deployed the application to Cloud foundry local bosh lite installation. I created one user provided service for postgresql and bound it to my application.
The app is working fine till now. Then i wanted to make this application as a service broker. So i again used spring boot cloud foundry service broker.
And implemented my code same as the sample mongodb spring boot service broker.
https://github.com/spring-cloud-samples/cloudfoundry-service-broker
But now when i am trying to start the application. It is failing with following error.
2017-06-20T17:16:19.82+0530 [DEA/0] OUT Starting app instance (index 0) with guid 65b656e1-fbe4-4a7f-bc34-6c410dbb3a4e
2017-06-20T17:16:23.07+0530 [DEA/0] ERR Instance (index 0) failed to start accepting connections
2017-06-20T17:16:23.09+0530 [API/0] OUT App instance exited with guid 65b656e1-fbe4-4a7f-bc34-6c410dbb3a4e payload: {"cc_partition"=>"default", "droplet"=>"65b656e1-fbe4-4a7f-bc34-6c410dbb3a4e", "version"=>"432ef489-14e3-44d7-bab8-bdd64bc8d9d3", "instance"=>"9bf4bd1c3a8741508a6b33da9ba76400", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1497959183}
2017-06-20T17:16:23.09+0530 [API/0] OUT App instance exited with guid 65b656e1-fbe4-4a7f-bc34-6c410dbb3a4e payload: {"cc_partition"=>"default", "droplet"=>"65b656e1-fbe4-4a7f-bc34-6c410dbb3a4e", "version"=>"432ef489-14e3-44d7-bab8-bdd64bc8d9d3", "instance"=>"9bf4bd1c3a8741508a6b33da9ba76400", "index"=>0, "reason"=>"CRASHED", "exit_status"=>127, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1497959183}
I searched over the net, it seems the error is related to ports and when the port is inaccessible.
https://github.com/cloudfoundry/cf-release/issues/649
but i have not defined any port for my application and i hope CF automatically assigns a port for my application
Best Regards,
Saurav
I have deleted the application and then deployed again.
It started working.
I know this does not tell the root cause . But may be a spring boot /cloud foundry framework developer can tell the root cause.
There was one point i would like to highlight.
The application is developed as a spring boot cloud foundry service broker Initally when i had deployed the application, it asked an username/password for me . I did not know about this earlier. Might have given wrong usernames and password and then pressed cancel.
After that the application was throwing the above error.
But it has to be noted that a spring boot cloud foundry service broker application already has spring boot authentication built in where password is already generated with username being "user".
Check more details here https://github.com/spring-cloud/spring-cloud-cloudfoundry-service-broker#security
I don't know if this was the reason. But a delete and redeploy worked with me.
Best Regards,
Saurav

Spring Cloud Sidecar is not working as expected

Based on the documentation, the #EnableSidecar annotation acts as a proxy for non-JVM applications that wish to register in Eureka. Accordingly, the configuration to be set is:
sidecar:
port: 81 <-- Port of the non-JVM application
health-uri: http://10.135.16.50:${sidecar.port}/api/health.php <-- URI of the non-JVM application's health endpoint
home-page-uri: http://10.135.16.50:${sidecar.port}/
Once the "sidecar" is up and running, we should be able to invoke one of the non-JVM endpoints through the service registry just by using the name that the "sidecar" application used to register in Eureka. So for example, if our "sidecar" application was registered in Eureka as "php-sidecar" to proxy a PHP application with an endpoint such as:
http://10.135.16.50:81/api/microservice.php
Then we should be able to invoke the following endpoint to get to the non-JVM application (assuming "sidecar" is in "localhost" and port 8080):
http://localhost:8080/php-sidecar/api/microservice.php
However, this is not working as expected. When we request the URI just above, a request to "localhost:81" is actually issued, because somehow the "sidecar" is picking up its host URI and not the home-page-uri defined as part of the sidecar's properties.
If we run the non-JVM application locally using localhost, then everything works as expected, but this is definitively not the realistic use case.
Therefore, what am I missing in my configuration to tell Spring Cloud (Zuul in this particular case) to use the non-JVM home-page-uri and not my local host URI?
Thanks for your support.
After some research, it turns out that the sidecar must always be deployed in the same host as the non-JVM application.
After some research, it turns out that the sidecar must always be deployed in the same host as the non-JVM application.
No, You can add sidecar.ip-address = 10.135.16.50 to your yaml config file
I'm using spring-boot-starter-parent version is 1.5.6.RELEASE
working fine

Resources