Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in RMI based chat server...

 
Mukesh Netedge
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I have created a chat server using RMI.
The chat client is developed as java applets.
I am using tomcat 4.1.X web server.
When i deploy the chat server on our intranet then
applet interacts with the RMI server and creates chat
session as per the functionality.
When i deployed the same application on our webserver
(on internet) the the application is not working at all.
I have tried few things like changing the java policy
files, running the tomcat with -security option, but all
in vein.
Please help me.
Thanks in advance.
Mukesh
 
raimondas zemaitis
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
firewall might be the reason. If you are under the firewall RMI can't get through. You should get the idea about the problem if you look at Java plug-in console in the browser.
 
Mukesh Netedge
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks raimondas zemaitis,
I have seen the java console. It shows secutiry exeception and prmpt for permission on port no 1099. When i given the permission on this port then it shows the same error with different port no. I also used "1024-" for permissioning but of no use.
Please help me.
Mukesh
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two questions:

1.) The RMI server and the webserver providing the page containing the applet must be same. I also think that you must be consistent with identifying this machine - if you look up the page using the IP address the IP address must be specified in the policy file, if you look it up using the domain name, you must have the domain name in the policy file. You might already have all this in place correctly - just making sure.

2.) Can you post the contents of the policy file you are using?

Thanks,
 
Mukesh Netedge
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nathan,
Here is the policy file which i am using....
// Standard extensions get all permissions by default
grant codeBase "file:${java.home}/lib/ext/*" {
permission java.security.AllPermission;
};
// default permissions granted to all domains
grant {
// Allows any thread to stop itself using the java.lang.Thread.stop()
// method that takes no argument.
// Note that this permission is granted by default only to remain
// backwards compatible.
// It is strongly recommended that you either remove this permission
// from this policy file or further restrict it to code sources
// that you specify, because Thread.stop() is potentially unsafe.
// See "http://java.sun.com/notes" for more information.
permission java.lang.RuntimePermission "stopThread";
// allows anyone to listen on un-privileged ports
// allows anyone to listen on un-privileged ports
permission java.net.SocketPermission "*:1024-65535", "connect,accept";
permission java.net.SocketPermission "*:80", "connect";
permission java.net.SocketPermission "*:1024-", "listen";
permission java.net.SocketPermission "*:1099-", "accept, connect, listen, resolve";
permission java.net.SocketPermission "*:8080-", "accept, connect, listen, resolve";

// "standard" properies that can be read by anyone
permission java.util.PropertyPermission "java.version", "read";
permission java.util.PropertyPermission "java.vendor", "read";
permission java.util.PropertyPermission "java.vendor.url", "read";
permission java.util.PropertyPermission "java.class.version", "read";
permission java.util.PropertyPermission "os.name", "read";
permission java.util.PropertyPermission "os.version", "read";
permission java.util.PropertyPermission "os.arch", "read";
permission java.util.PropertyPermission "file.separator", "read";
permission java.util.PropertyPermission "path.separator", "read";
permission java.util.PropertyPermission "line.separator", "read";
permission java.util.PropertyPermission "java.specification.version", "read";
permission java.util.PropertyPermission "java.specification.vendor", "read";
permission java.util.PropertyPermission "java.specification.name", "read";
permission java.util.PropertyPermission "java.vm.specification.version", "read";
permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
permission java.util.PropertyPermission "java.vm.specification.name", "read";
permission java.util.PropertyPermission "java.vm.version", "read";
permission java.util.PropertyPermission "java.vm.vendor", "read";
permission java.util.PropertyPermission "java.vm.name", "read";

};

Thanks
 
Mukesh Netedge
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
When i run chat applet on client machine it throwing an error as follow:
java.rmi.ConnectIOException: Exception creating connection to: 192.168.2.155; ne
sted exception is:
java.net.NoRouteToHostException: Operation timed out: no further informa
tion
java.net.NoRouteToHostException: Operation timed out: no further information
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at SMH.SMHchatterImp_Stub.openWindow(Unknown Source)
at SMHserver.SMHdatabaseServerImpl.assign(Unknown Source)
at SMHserver.SMHdatabaseServerImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Sour
ce)
at java.lang.Thread.run(Unknown Source)
Please help me....
Thanks in advance.
Mukesh.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats the problem... the address - "192.168.2.155" looks like an internal intranet ip address. When the client is running on the internet they try to load that address and get nothing (try typing "192.168.2.155" into a web browser - I get a TCP error because nothing is running at that ip address). Find out where the value "192.168.2.155" is coming from (code/property file/etc.) and change it to the address of the machine from which the client is actually loading the page.
 
Mukesh Netedge
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nathan,
The ip address you have pointed is the local ip in my intranet.
This ip is not coded and not registered in any poperties file.
Let me explain the working of my rmi chat.
Chat applet is for client opens up from any desktop m/c like 192.168.2.155.
This applet then invoke another applet which is at different m/c. When any user start a new chat session the second applet automatically notify the user for new session.
Please guide me.
Mukesh
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is the error you get when trying to open a connection to "192.168.2.155" when the server is trying to notify *you* of the new session event, or is it passing you the IP address of the other applet and then you get the error when trying to access that IP address?

In the JavaDocs for NoRouteToHostException it states that a firewall or a Router failure could be the cause of this exception. I'm thinking that this may be a firewall problem... the firewall may be set up so you can access the ports of the web server, but the web server can't access ports on your machine.
 
Mukesh Netedge
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot nathan,
You are abosolutely right. When i open my applet on a machine which directly connects to internet the chat is working fine.
Now please suggest me some solution to run my chat across the firewall/proxy server.
Thanks in advance.
Mukesh
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a pretty good description of what to do in the JGuru RMI tutorial. You can search google for "RMI HTTP tunneling" for more information on this topic, too.
 
Mukesh Netedge
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nathan,
I was going through http tunneling but i am not clear where i have to make changes so that to incorporate tunneling.
How rmi client(applet) will communicate to servlet?
Please guide me.
Thanks and regards,
Mukesh
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A servlet is exposed as a URL on the same server - the applet can access that URL using URLConnection or HttpURLConnection.
 
Mukesh Netedge
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks nathan for your support.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic