Not able to access deployed web application other than on local computer - java

I am trying to deploy a web application with a url say
http://10.x.x.x:8080/test using apache tomcat. This works from local computer.
The problem is the address 10.x.x.x is my ipv4 address and when i try to hit this from other computers its not accessible.
Using noip / what is my ipaddress.com I also see that the public ip is different other than ipv4 address.
Even if i try http://1.x.x.x:8080/test it dosent work. Moreover i found that when i do a ping 1.x.x.x from command prompt it times out without success.
I am using an wifi dongle.

10.x.x.x is an IPv4 private IP address. It is not addressable outside of your "local network". The chances are that your computer doesn't have a public IP address at all.
Your computer is probably talking to the outside world via a NAT server. By default, that only works for out-going connections. Depending on how your networking is set up, it might be possible to configure the NAT server to map a port on its public IP address through to port 8080 on your computer.
But this is not a programming issue. The question doesn't belong here.

Related

Connecting to localhost from devices outside the network

I am currently doing an project at the university where we have to develop a multiplayer roleplay game with an client-server architecture. My part is to develop a Java Server which responds to client requests.
What do i have to do so my teammembers are able to connect to my localhost server?
If you want clients outside your local network to be able to see your server, you'll need to use something like ngrok. It's designed for exactly this. https://ngrok.com/
If your clients will be connecting from inside your network, they will need your machine's ip address. They can type it into their browser window. If you're running your java server on a port other than 80, then they'll need to add that to the url.
// from inside the network
example: http://192.168.1.125:80
example: http://192.168.1.125:3000
example: http://192.168.1.125:5000
// from outside the network
example: http://yourNgrokName.ngrok.com
Usually all the computers (i.e. macOS, linux, windows) have at least a double interface (localhost) which is not reachable outside and an external interface (wifi or ethernet) that is reachable from outside.
On most computer systems, localhost resolves to the IP address
127.0.0.1, which is the most commonly used IPv4 loopback address, and to the IPv6 loopback address ::1. The name localhost is also a
reserved top-level domain name, set aside to avoid confusion with the
definition as a hostname.
If you want that your team members are able to reach your computer, you have to use the address of this second interface.
But in this case, there could be many problems related to your personal firewall, network topology and etc.
The word outside itself is very generic because, outside could mean:
computers in my home network (small size)
computers in my office network (small-medium size), may be spread across more buildings
all the computers on the internet
Different network problems arises when you want that you personal computer is reachable from outside.

Change localhost to something like localhost.dev in dynamic web project

I am creating a dynamic web project in java. I want to deploy it in a application server. By default we have hostname as localhost:port/appname. I want to change it to localhost.com/myapp. How can i do that? Do i need to change something in my project or tomcat or hostfile. Please elaborate.
I fear there may be some confusion about how web servers work.
In your browser the URL http://localhost:8080/application_name will resolve internally to 127.0.0.1 (localhost) as this is a built in address. 127.0.0.1 is a loop back address pointing to the machine you're on. If you're hosting the server on the same machine as the you're trying to navigate to this is why the localhost address works.
If you were on another machine you would need to either directly input the IP address of the server or use a DNS record to point the IP address to a URL you own and control.
Browser are also programmed to default to port 80 for http and port 443 for https so if you don't want to have to provide a port have your server bind to port 80. This way you'll only need to navigate to http://localhost/application_name
When deploying the application to a server you want to be externally accessible you'll purchase a domain, register the DNS record and point it at servers external IP address (You may need to configure firewall and network rules).

JVisualVM remote working when destination is behind NAT?

I am in developer network and the JBoss to be monitored using JVisualVM is behind client firewall in separate network. JBoss is exposed to us through a NAT. The exposed JMX port works when using telnet from our developer network, but JVisualVM still doesn't find the remote JMX. Apparently this can be due to two things: 1) one or several dynamic RMI sockets need to be accessed, or 2) the "java.rmi.server.hostname" is not defined. My problem may be both points 1 and 2, but apparently since we have SSH access this can be tackled according to this site:
http://rafaelsteil.com/setting-up-jmx-for-jconsole-visualvm-on-ec2-plus-jetty-configuration/
“java.rmi.server.hostname” is the public hostname (like example.com) of your server, without HTTP or anything else. You cannot use an internal address, otherwise you won’t be able to remotely access the service.
However I have one question about the "java.rmi.server.hostname", should the defined IP address be the server internal IP or NAT IP which is publicly expoed to our developer network?
I have actually just tackled this problem myself and figured it out.
I would wager that the problem is the RMI connections - you can't predict which ports it will use and so you can't get it to work with a firewall.
The workaround is to use an SSH proxy:
SSH to the box where your application is running but use the -D option like this:
ssh user#remoteHost -D 9999
This will start a socks proxy on your local machine on port 9999.
Open JVisualVM and in the preferences, under 'network' configure it to use a socks proxy at localhost, on port 9999.
If you do the above, you should then be able to connect to the remote machine as normal and since all the RMI traffic is now going over the SSH proxy, it is punched through the firewall and works nicely.
Good luck :-)

Socket communication on Android localhost

I'm developing multiple applications which need to communicate with each other via socket. First I need them to be able to communicate on localhost. So when I'm running both of them at the same time on my phone they can communicate (I know that there are easier ways to do this on the same phone but in the future they will run on separate phones).
My code for socket communication is very similar to this: link
Difference is that my apps are running this as foreground services.
I've set the ip for the server on the client to 127.0.0.1 but they just won't connect (not in the emulator and not on real phone). What am I missing?
UPDATE:
I've found an easy way to get the device own IP address, so instead of localhost I use this (with www.google.com domain): answer to "java InetAddress.getLocalHost(); returns 127.0.0.1 … how to get REAL IP?"
Maybe it's not too nice but it works.
You'll need to set the local IP address of each one, so they can communicate within your LAN. So use an address like 192.168.1.X. Both if you're running your devices as virtual or physical, you may easily know the local IP address they have accessing your router's web interface and seeing their bound IPs.

Java TCP/IP Chat Room, how to make it work over internet

I have fully developed a chat room for multiple clients with multi-threaded server which does the job, however only on my local machine. I want to go beyond this, and make this chat room to be working over the internet. So far I have made the port forwarding on my router for TCP protocol to route to my local IP address, however this didn't solve the problem and I still can't connect the client, even on my own local network. What other steps should I follow to get my chat room working on my own local network and then the internet?
try disable (windows) firewall ?
So my friend the basic rule for make anything to work over internet is to do Port forwarding or in simple way you can say that to open your server for the public network. For that you need to make sure that the routing path is complete from internet machines to your desktop. For this to work you need to open the port for which you need to access your machine from firewall settings, and also ensuring that trafic is routed from your public IP address to the server's IP as your server will be private under some router or ISP.
Way to do that:
You need to configure your home network i.e router setting. So in your router, configure the port you want the communication to happen(say port 5443).
In your router, configure a port-forward for the port 5443 to the internal IP address of your actual server, also to port 5443.
Reference: https://www.noip.com/support/knowledgebase/general-port-forwarding-guide/
On your server(your Desktop Machine) ensure that your firewall settings for port 5443 is on and set to allow rather than block.

Categories

Resources