I have created a test program between two virtual machines on my computer. So I have an RMI Server running on a virtual machine on VMware and I have an RMI Client running on another virtual machine on VMware.
I have set up SSL using SslRMIServerSocketFactory and SslRMIClientSocketFactory and it is possible to call methods from the client to the server, having the server to respond with the return value. So right now I have two Ubuntu machines running on VMware.
What happens is that the client makes the call to the server and I have to wait for about 17 seconds until the response from the server reaches the client and the print is executed on console. Updated: The method's call is fast. All this time is taken by the Registry.lookup() function.
Aren't 17 seconds too much time?
I know that VMs are slow by nature, plus the fact that SSL is running but still, aren't 17 seconds too much for what I am doing? The remote method only adds two integers and returns the result.
Thank you.
Java does reverse DNS when it either connects or accepts a socket, for security purposes. You didn't have any DNS or reverse DNS information about the server available at the client, or about the client available at the server. Putting a server entry into the client's /etc/hosts file and a client entry into the server's /etc/hosts file fixed that. Otherwise it would try via a DNS server and timeout waiting for a response before proceeding.
I had the same problem connecting my RMI client to the RMI server on the same machine.
In my case even the instantiation of an object inheriting from UnicastRemoteObject in the server caused a delay of more than 20 secs. Configuring /etc/hosts with localhost didn't fix the problem and I had to use this line in my java application before using RMI:
System.setProperty("java.rmi.server.hostname", "127.0.0.1");
Related
I have a Corba application in Java working on my PC. Both the client and server running on one PC. Now I want the server and client running on different PCs and establishing a connection between them but I'm not sure how to do it I tried looking for a solution online but no luck so far.
As long as you pass the object reference to your client you can put your server on any machine. You could pass the IOR as a stringified form (e.g. IOR:....) or as a corbaloc string.
For example see https://github.com/JacORB/JacORB/tree/master/demo/hello
I have a legacy server application written in java which has been running fine over the last six years on a windows 2003 machine running Java 6.
We recently migrated the application to a brand new windows 2008 machine running the latest version of java.
Although the application seems to work fine, there is one weird issue
The code String remoteip=socket.getInetAddress().getHostAddress() seems to return the internet IP of the server machine instead of returning the IP of the remote client.
This was working properly on both Linux and Windows 2003 machines over the last 6-7 years.
To double check all settings, I set up a small php website on IIS and printed the value of REMOTE_ADDr variable. It printed the correct IP address of the client.
Any clues on what could be confusing the java app?
The Java doc says this:
getInetAddress()
Returns the local address of this server socket.
Probably previously you were running the server and the client on the same machine.
To be more specific: You probably have a ServerSocket(sSocket) waiting for connections from clients.
If you call sSocket.getInetAddress(), you will get the IP address of the server.
On the other hand, the role of a ServerSocket is to bind to a IP address and port and to wait for connections from clients. When such a connection is made, the sSocket.accept() method returns a Socket which represents the connection of the server to that specific client (cSocket). Calling cSocket.getRemoteAddress() returns the IP of the client
I have a client/server applciation that communicates through JNDI/RMI/IIOP using, on client side, some Glassfish client code (NOT packaged as a Glassfish client) and on server side a Glassfish instance.
I have some Glassfish multimode scripts that I use to make sure the domains I create on any machines are totally identical and correctly configured.
Using that script on local network, I have already made sure I could access a remote Glassfish server instance from client code on my machine (that was quite a reasonable guess, however I tend to test all things I'm not totally sure of).
Next step is to have that client/server application working over (I should instead say "through") internet : with my client code in my company LAN (in other words on my machine) and my server code on an Amazon VM running my Glassfish server. For some reasons, the remote Glassfish is running on a Windows VM.
Obviously (as I ask that question, you can safely guess the through internet test is NOT working. And you're right.
So, to have more guesses, I started SmartSniffer both on my machine and on server.
On my machine, I can only see one TCP packet going to that server instance (and nothing coming back).
On server instance, I can see one packet entering (the client query) and one packet exiting (the server answer). That server answer looks like this :
[4/4/2012 11:47:13 AM:917]
GIOP.......(................NameService....._is_a...................NEO................ª.......(IDL:omg.org/SendingContext/CodeBase:1.0............n........172.27.63.145.Ô2....¯«Ë........e...........................
...................
... ...........&...............(IDL:omg.org/CosNaming/NamingContext:1.0.
That 172.27.63.145 address is my IP in local network.
[4/4/2012 11:47:13 AM:917]
GIOP.......2............NEO................0.......(IDL:omg.org/SendingContext/CodeBase:1.0............ô........46.137.114.###.'5....¯«Ë........d...........................
...................
... ...........&...........!...|...............$...
...f............10.241.42.###.'6.#........g..............g........default...................g...............+IDL:omg.org/CosNaming/NamingContextExt:1.0.............¢........10.241.42.208.'5...M¯«Ë....
...d... S1AS-ORB............RootPOA....
TNameService............................... ...................
... ...........&......
That 46.137.114.### is external one of my Amazon VM, and 10.241.42.### is its internal IP in amazon magical virtual server.
So it seems server is answering, no ?
But that answer never finds its way to my machine in my network.
So ... how can I check where it get lost ? Seems likepacket sniffer has done its job, but what can I do now ?
NOTE This question is a clarification of "How to Connect a glassfish client to glassfish server over NATs?"
Perhaps stupid question, but is your Amazon EC2 instance is configured with all required ports open for your communication protocol to work? You could see configured open ports in security group your instance assigned to in AWS console, under EC2->Security Groups.
I have not worked much on virtual machines and I need some help in resolving the virtual machine problem. Here is my set up.
I have two linux systems with Virtual Box VB1 and VB2 installed on each one.
Created two guest windows 2000 virtual machines in each of the virtual box.
Configured the ethernet adapter to use Bridge adapter for network connections.
I am running to run a corba server on one of the win2k guest on VB1 and running a client on one of the win2k guest on VB2. On running the client I get connection refused exception. This happens only when I run the server and client on two different virtual boxes.
"Connection refused" simply means that the client cannot open a TCP/IP connection to the server computer. That could be due to any of the following reasons:
The client is trying to connect to a server other than the one you expect
The server is not listening for incoming connections
Windows firewall is blocking incoming connections from the client
There is no TCP/IP connectivity between the machines at all (although it sounds like the DNS lookup happened correctly, otherwise you would have seen a "unknown host" error)
This is a networking issue, so to diagnose it you should try and increase the logging on your client to make sure it's connecting to the right host/port. If that doesn't help, increase the logging on the server to make sure it's listening on the correct port.
Also, if your CORBA application is using insecure IIOP then you could always turn on ethereal sniffing on your client box to see where it's connecting to.
Ok, I myself resolved the issue. The issue was with configuring the virtual machines. I had to use "Bridge Network Adapter" as a NIC card in each of the vm, earlier I was using NAT.. so this solved the problem.
I know my RMI app works correctly - it works fine when the server is on localhost and inside the LAN but when connecting to an external RMI server it fails when trying to make stub calls
So the server is bound to localhost (an internal IP - 192.168.1.73) but the client is specifying an external IP (45.4.234.56) - which then gets forwarded to the internal server. How do you resolve this problem?
thanks
The "simplest" approach is for your network admin to add IP forwarding from a specific port on the firewall to your server.
Assuming this isn't an option (and it probably isn't), then RMI supports tunnelling over HTTP. The performance is poor, but it's much more firewall-friendly.
http://java.sun.com/javase/6/docs/technotes/guides/rmi/faq.html#firewallOut
This well-worn method is popular since
it requires almost no setup, and works
quite well in firewalled environments
which permit you to handle HTTP
through a proxy, but disallow regular
outbound TCP connections.
If Java RMI fails to make a normal (or
SOCKS) connection to the intended
server, and it notices that a HTTP
proxy server is configured, it will
attempt to tunnel Java RMI requests
through that proxy server, one at a
time.