Spring boot, remote host - java

I want to check my rest api service remotely, for this purpose i add the following lines to application.properties
server.port = 8080
server.address = 37.221.202.142
This ip address i got from this site https://2ip.ru/
But when i run my app i have the error like port is already in use. I switched a lot of ports( 8081,8082,8083 etc) but every time i got this error. When i removed this line from application.properties server.address = 37.221.202.142 Application is deployed fine but i can't connect to server using this url http://37.221.202.142:8080/managers, but this work fine http://localhost:8080/managers
What am i doing wrong?

Open command prompt and type ipconfig(if you are a windows user) or ifconfig(if your linux user).
Get the ip address of your machine. I assume you are not deploying the application in public server(azure or aws).
If your using Tomcat or Pivotal Server for deploying the war file. Double click on the sever to get the Overview of the server details and just type your IP address.
Now, restart the server and hit the IP address YOURIPADDRESS:8080 port in the browser and it should work.

Related

Tomcat with 18080 port can see that web can success host, however, without any port doesnt show

Currently I am hosting WAR with tomcat.
However, I find that if we host web by port 18080,
just like http://my-server-site:18080/welcome
the page can show successfully.
However, if i just type :
http://my-server-site/welcome
it said cannot find directory '/welcome'.
Anyone have idea why looks weird?
Thanks
Not weird at all...
If you do not specify a port, it will default to 80 for HTTP and 443 for HTTPS. I guess you have another web server (apache?) running on the same host that give you the error you see.
If you are expecting to see the same page on the default port, you will need to configure your web server as a proxy. ProxyPass for apache and proxy_pass for nginx.

Accessing Spring boot Application refused to connect with IP 192.168.99.100 running in docker tool box

I am running a spring boot application in docker tool box. The application runs on port 8380 as set in application properties. However, when i run its image in a container, I am publishing with ports 8380:8082. When i access it from ip 192.168.99.100 (my docker machine ip) and port 8380, it gives me ERR_CONNECTION_REFUSED error. 192.168.99.100 refused to connect.
Any ideas what might be wrong?
I have tried using localhost instead of docker-machine ip. I checked the access url from kitematic i.e 192.168.99.100:8380. Using this it does not work.
Here is my DockerFile:
FROM java:8
EXPOSE 8082
ADD /build/libs/tsi-csrportal-gui-2.0-SNAPSHOT.jar dockerDemoCsrportal.jar
ENTRYPOINT ["java", "-DTSI_APP_NAME=csrportal", "-DTSI_ENV=test", "-Dtsi.log.console", "-jar", "dockerDemoCsrportal.jar"]
I expect the service to give json response when I access with the proper endpoint. Similar to when I run the spring boot application without docker toolbox. (Only change is that now I use docker machine ip instead of using localhost)
When you expose a port in docker it means you can access to that container using [container_ip]:[exposed_port].
But when you map the exposed port to another port it means that you can access to the container using [host_ip]:[mapped_port].
So you can access like localhost:8380 or 192.168.99.100:8082

How to bind DatagramSocket to particular port in Openshift

I am running siple java jar service on openshift which tried to connect with DatagramSocket and Getting this Exception:
java.net.BindException: Permission denied
at java.net.PlainDatagramSocketImpl.bind0(Native Method)
at java.net.AbstractPlainDatagramSocketImpl.bind(AbstractPlainDatagramSocketImpl.java:96)
at java.net.DatagramSocket.bind(DatagramSocket.java:397)
at java.net.DatagramSocket.<init>(DatagramSocket.java:251)
at java.net.DatagramSocket.<init>(DatagramSocket.java:304)
at java.net.DatagramSocket.<init>(DatagramSocket.java:276)
at com.gasmps.service.TerminationListener.run(EmailService.java:542)
at java.lang.Thread.run(Thread.java:745)
I know this is port permission problems but i tried with port like 8000,8443,15005,16005 but getting same how could i resolve this? How i can know all open port that can i use in my application.
Edit: My jboss server is already running in the same application and I don't want to create separate application for these jar service bcos I have to run this jar from my application from remote location.
Iv looked into this before after having the same issue and discovered the answer on stack-overflow before:
In Openshift, you may only bind to the port that the server allocates
for you. Typically that is the value of the environment variable
$OPENSHIFT_JBOSS_PORT (it varies between cartridges) and the value
differs between gears. Binding to any other port will be reported as
an SELinux policy violation and denied.
link
The port is usually 8080
you can bind your app to 8080 (not to 8000 or 8443), all traffic >received on 8000 and 8443 will be routed by the proxy to your app >listening on 8080.
This worked for me, but let me know how it goes and if it still doesn't work i'll try and help.

Timeout while deploying Java Application to remote glassfish server from Netbeans

while deploying to a remote Glassfish 4.1 Server from Netbeans 8.0.1, i get a Timeout.
I configured the Glassfish Server by adding a new Server Instance and that seemed to work. I can see the applications running on the server and i am able to undeploy a application (directly from netbeans).
But when i try to deploy my application to the remote Server, i get a timeout Exception.
(i used enable-secure-admin to gain remote access from netbeans to the server)
What confuses me is, that when i enabled secure admin, i expected to see a https:// url in netbeans. But this url starts with http:// and i cant find an option to change this.
Server Attributes:
Host: [remote-ip]
DAS Port: 4848
Domain: domain1 (same as on the remote server)
Target: empty
Username PW : as set on the remote server
"Enable JDBC Driver Deployment" and "Preserve Sessions Across Redeployment" are checked
Could you please attach the logs.
most probably its issue with the grizzly jar.
Please try the patched grizzly jar and see if it works for you.
Checkout : https://java.net/jira/browse/GRIZZLY-1713 for the same

CONNECTION_REFUSED from Apache 2.2 server ( the channel to weblogic 10.3.6 server)

I built a web-service application using Jdeveloper 11.1.1.7 and deployed on weblogic 10.3.6 on physical server let us call it back-end server.
I do not want to give client direct access to back-end server so I make use of Apache 2.2 to be in the middle of client and back-end server. Apache 2.2 is configured on different physical server let us call it middle server.
I defined application's context root (which deployed in back-end server) on middle server in Apache httpd.conf file.
I shared WSDL file location to client ( WSDL URL which referring to the middle server domain name). The external client can access the URL thorug browser where he/she can see the WSDL content
But when the client trying send requests to middle server URL it get rejected with the following error:
[error] [client -clinet public IP goes here-] ap_proxy: trying POST /[application context root goes
here] at backend host '[back-end server local IP]/[port goes here]; got exception 'CONNECTION_REFUSED
[os error=0, line 1602 of URL.cpp]: apr_socket_connect call failed with error=730061, host=[back-end
server local IP], port=[port goes here]'
This error from middle server Apache error log file. No logs from back-end server
What is done so far:
I check the if I can access the middle server as external user using the telnet command. telnet IP port. It is working and the middle server is listening.
I also checked for all ports. between external client and middle server, between middle server and back-end server also using telnet. All ports working.
In this answer : ssl - Apache 2 with Weblogic Plug-in Redirection, original location still requested to backend - Server Fault
they are suggestion to increase the Accept Backlog value from weblogic server tuning . I did that in back-end server but still the issue is not resolved.
Problem resolved
I need to enable (WebLogic Plug-In Enabled) option from weblogic server where the application is deployed
from Domain Structure (Left Panel in admin console) - > Environment - > Servers -> (select the server where you deploy your application on it) - > General tab (from server setting)-> Advance - > (tic the option) WebLogic Plug-In Enabled
Then restarted the server.
By this your are telling the server you will get indirect request through proxy server or load balancer for example
You can do this on many level like cluster or server based on your needs check this site for more information
Understanding the use of “WebLogic Plugin Enabled”

Categories