This question already has answers here:
Connecting to a VPN without installation of client software
(3 answers)
Closed 8 years ago.
I am trying to write a client-server program in Java. There are a lot of working examples with using localhost as IP of the server. I am using VPN and running client and server codes on different computers in same network. But client can not connect to this server when I provide ip given after running VPN (such as 12.123.45.32). I generally get timeout error even if I set it to a large number. But if I use local IP such as 192.168.1.10, it works and connects.
I also wonder if there is a way for client and server to communicate with using server's public IP (without any VPN).
Any suggestions?
Thanks..
There is no problem in accessing a server through public ip or domain name. Only problem can be address renewal. Other than that you need to make sure the correct ports are forwarded in your router / firewall.
Are you using sockets or RMI?
Sockets shouldn't be a problem, but RMI require you to setup a SecurityManager or something like that. Honestly I have never gotten RMI to work over internet; I have stuck with sockets.
I wouldn't bother with VPN at all. Way too unstable imho. I only use VPN if I'm unable to setup company router for access.
Related
This question already has answers here:
RMI lookup works but method invocation not
(2 answers)
Closed 3 years ago.
So I have a very basic client-server program running on my local lan network.
The program consists in the server being a permanent listener, adding every client who connects to his ip to a list of observers and updating them every 5 seconds (Client Extends UnicastRemoteObject).
The problem is that I don't know why the client creates a reference using an unknown ip address.
This is what I usually get from the client, if I type System.out.println(this):
RmiClient[UnicastServerRef [liveRef: [endpoint:[192.168.56.1:64199](local),objID:[32218df3:16acc934a0a:-7fff, 8241015111525045915]]]]
I did some research and I found that ip address belongs to my VirtualBox Host-Only Newtork interface, so when I disable this I get the correct infos:
RmiClient[UnicastServerRef [liveRef: [endpoint:[192.168.1.3:64307](local),objID:[1b156947:16acc999fa5:-7fff, 6095931207093481175]]]]
Which is the correct ip of this machine on my lan.
My question is how do I make this work without permanent disabling the interface?
Also if I set server and client on different machines, I get a RemoteException when the server tries to update the clients because it tries to contact 192.168.56.1 and obviously fails.
Solved! The problem consisted in the Client extending UnicastRemoteObject.
Apparently I had to set the property java.rmi.server.hostname in both client and server applications, but in the client that wasn't working because of the extension.
So I managed to solve by eliminating the extension and adding the following code:
UnicastRemoteObject.exportObject(this, port);
This way the propery works correctly on the client.
This question already has answers here:
How do I get the remote address of a client in servlet?
(11 answers)
Closed 3 years ago.
I am sending request from my machine to server. Ip address of my machine is 192.168.1.217.
At server side I am printing the client Ip address, but when I am printing Ip address with request.getRemoteAddr() I am getting it as 192.168.0.5.
When I am printing Ip address with request.getHeader("X-FORWARDED-FOR") I am getting it as null.
I am using apache tomcat server.
If that IP address (192.168.0.5) is the (or a) firewall, then it is the right IP address. Your server-side code is reporting the "client" IP address that it sees, and it can't do any better.
In general, there are a couple of possible explanations as to what is going on:
The firewall could be running an HTTP proxy, and your client machine could be configured send all HTTP requests through the proxy. If the client is capable of talking directly to the server, then you may be able to modify the client's proxy settings to treat the server as an exception.
The firewall could be providing a NAT service that is isolating one part of you networks from another part (for example). If this is the issue, then you will need your network administrators' help.
It is common (and often "good practice") to run a Tomcat server on (say) port 8080, and put it behind a reverse proxy on port 80.
In your case, the first explanation is most likely.
#andrucz suggests using the Tomcat Remote IP Filter. That will work in some circumstances, but not all, and it is using information that can easily be "spoofed"
The bottom line is that it is common for a webserver to not be able to see the real IP addresses of clients. So it is inadvisable to implement your services to depend on this.
You can use Tomcat Remote IP Filter: http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Remote_IP_Filter
Maybe you will need network administrators' help to configure firewall to include "X-Forwarded-For" header.
This question already has answers here:
RMI cannot connect to remote server
(2 answers)
Closed 9 years ago.
I can't seem to connect 2 machines using RMI. To make sure there wasn't something wrong with my code I copied the simple example from wikipedia (http://en.wikipedia.org/wiki/Java_remote_method_invocation) and I edited the code to print out a simple int.
I tried giving all permissions and turning all the firewalls off and I still get this error:
java.rmi.ConnectException: Connection refused to host 55.229.xx.xxx; nested
exception is:java.net.ConnectException: Connection timed out: connect
I've been trying to do this for the past 3 days and I still can't seem to get past basic configuration problems.
The Problem could be your RMI server is sending back its local address, instead of WAN address.
System.setProperty("java.rmi.server.hostname", *host IP*);
also take a look at security policies regarding RMI:
http://docs.oracle.com/javase/tutorial/rmi/running.html
Check your firewall settings on your aws instance
RMI is running on 1099 port by default as i remember.
This question already exists:
How to setup a network such that two computers on different network appear to be on same subnet [closed]
Closed 8 years ago.
I have to write a program for both sides, server and client (client and servers might have different location). Both sides communicate with each other using RMI. But I guess RMI doesn't work when computers on different sub-net, as RMI uses sockets. I want to know how I can setup a network such that two computers on different network appear to be on same subnet and RMI can work or any other way I can solve this problem. I had previous issues with sockets and I here's the link for the thread.
This is not a homework/school project, I am developing this software for my college.
not able to connect through socket
I guess RMI doesn't work when computers on different sub-net, as RMI uses sockets.
You guess wrong.
As long as the subnets have a route to each other and the appropriate ports are open they can communicate via sockets without problems.
In the case of RMI that usually means just port 1099, and taking the steps necessary to ensure that all remote objects are exported on that port. An in-memory Registry is also required, via LocateRegistry.createRegistry().
Your prior thread is of no relevance, as it only concerned an invalid IP address. If you think it constitutes proof of your bizarre claim about subnets and sockets, think again.
This question already has answers here:
How to get the list of IP addresses in a LAN?
(2 answers)
Closed 9 years ago.
Recently, I created a client/server application by java, they connect is fine, but when i test it in my school network, it can not work fine anymore, so, i need some code that return all IP of Lan network into an array so that i can put it in a JComboBox, the code should be non-blocking so it cannot hang my application.
P/S: I have been try brute-force method (like other answer) to get all IPs but it just hang my application and really not reliable.
Anyway, thank for your help.
~Best Regard and have a nice day
it can not work fine anymore, so, i need some code that return all IP
of Lan network into an array so that i can put it in a JComboBox
Why would you need these IPs????
Problem could be:
Either you bind to localhost and when you deploy in different machines you can't connect. So don't bind to localhost.
Or there is a firewall. So unblock the firewall.
Or there is no route between the machines. Can you even ping it? (but if there is a firewall it will not ping also).
So you can troubleshoot it.