| | |
Rmi by Internet connection
![]() |
Hai Friends
Iam using RMI concept for my project, i want to connect client and server by using internet connection , but its working fine on LAN connection, it gives following Exception
125.17.11.229 is my internet IP
my code
plz help me for this problem...
Iam using RMI concept for my project, i want to connect client and server by using internet connection , but its working fine on LAN connection, it gives following Exception
Java Syntax (Toggle Plain Text)
java.lang.RuntimeException: java.rmi.ConnectException: Connection refused to hos t: 125.17.11.229; nested exception is: java.net.ConnectException: Connection refused: connect at Client.init(Client.java:23) at sun.applet.AppletPanel.run(AppletPanel.java:417) at java.lang.Thread.run(Thread.java:619) Caused by: java.rmi.ConnectException: Connection refused to host: 125.17.11.229; n ested exception is: java.net.ConnectException: Connection refused: connect at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198 )
my code
Java Syntax (Toggle Plain Text)
Server: import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; public class Server implements RemoteInterface { public String getMessage() { return "Hello World"; } public static void main(String args[]) { try { String REGISTRY_NAME = "RMI_Example"; int REGISTRY_PORT = 3032; Registry registry = LocateRegistry.getRegistry(REGISTRY_PORT); RemoteInterface remoteReference = (RemoteInterface) UnicastRemoteObject.exportObject(new Server()); registry.rebind(REGISTRY_NAME, remoteReference); } catch (Exception e) { throw new RuntimeException(e); } } } Interface: import java.rmi.Remote; import java.rmi.RemoteException; public interface RemoteInterface extends Remote { String getMessage() throws RemoteException; } client:import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import javax.swing.JApplet; import javax.swing.JLabel; import java.rmi.*; public class ClientApplet { public static void main(String arg[]) { String REGISTRY_NAME = "RMI_Example"; int REGISTRY_PORT = 3032; try { Registry registry = LocateRegistry.getRegistry("125.17.11.229",REGISTRY_PORT); RemoteInterface remoteReference = (RemoteInterface) registry.lookup(REGISTRY_NAME); System.out.println(remoteReference.getMessage()); } catch (Exception e) { throw new RuntimeException(e); } } }
Last edited by ~s.o.s~; Apr 30th, 2008 at 3:01 pm. Reason: Added code tags, learn to use them.
When iam using external ip(125.17.11.232) to connect server its working fine in LAN but it gives error when iam try to run in internet connection
Exception in thread "main" java.lang.RuntimeException: java.rmi.ConnectIOExcepti
on: Exception creating connection to: 194.9.30.245 nested exception is:
In error show my server local ip 194.9.30.245 ,
coding:
Server :
Server.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class Server implements RemoteInterface
{
public String getMessage()
{
return "Hello World";
}
public static void main(String args[])
{
try
{
String REGISTRY_NAME = "RMI_Example";
int REGISTRY_PORT = 60020;
Registry registry = LocateRegistry.getRegistry(REGISTRY_PORT);
RemoteInterface remoteReference =
(RemoteInterface) UnicastRemoteObject.exportObject(new Server());
registry.rebind(REGISTRY_NAME, remoteReference);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
}
--------------------------------------
Interface
RemoteInterface.java
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface RemoteInterface extends Remote
{
String getMessage() throws RemoteException;
}
-----------------------------------------------------------
Client
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import javax.swing.JApplet;
import javax.swing.JLabel;
import java.rmi.*;
public class ClientApplet
{
public static void main(String arg[])
{
String REGISTRY_NAME = "RMI_Example";
int REGISTRY_PORT = 60020;
try
{
Registry registry =
LocateRegistry.getRegistry("125.17.11.232",REGISTRY_PORT);
RemoteInterface remoteReference =
(RemoteInterface) registry.lookup(REGISTRY_NAME);
System.out.println(remoteReference.getMessage());
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
}
Please send me solution for this problem
Exception in thread "main" java.lang.RuntimeException: java.rmi.ConnectIOExcepti
on: Exception creating connection to: 194.9.30.245 nested exception is:
In error show my server local ip 194.9.30.245 ,
coding:
Server :
Server.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class Server implements RemoteInterface
{
public String getMessage()
{
return "Hello World";
}
public static void main(String args[])
{
try
{
String REGISTRY_NAME = "RMI_Example";
int REGISTRY_PORT = 60020;
Registry registry = LocateRegistry.getRegistry(REGISTRY_PORT);
RemoteInterface remoteReference =
(RemoteInterface) UnicastRemoteObject.exportObject(new Server());
registry.rebind(REGISTRY_NAME, remoteReference);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
}
--------------------------------------
Interface
RemoteInterface.java
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface RemoteInterface extends Remote
{
String getMessage() throws RemoteException;
}
-----------------------------------------------------------
Client
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import javax.swing.JApplet;
import javax.swing.JLabel;
import java.rmi.*;
public class ClientApplet
{
public static void main(String arg[])
{
String REGISTRY_NAME = "RMI_Example";
int REGISTRY_PORT = 60020;
try
{
Registry registry =
LocateRegistry.getRegistry("125.17.11.232",REGISTRY_PORT);
RemoteInterface remoteReference =
(RemoteInterface) registry.lookup(REGISTRY_NAME);
System.out.println(remoteReference.getMessage());
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
}
Please send me solution for this problem
Maybe, if you were to show what the nested exception is.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
That is, seemingly, not a publicly available ip address (i.e. can't be reached from the internet, at all), or you are attempting it to access throught the wrong interface on your computer, and so have no network path to it.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- IE Emergency: Cannot find server or DNS Error (Web Browsers)
Other Threads in the Java Forum
- Previous Thread: Javax.sound.midi and midi messages
- Next Thread: RMI server behind the firewall+nat enivironment
Views: 3023 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for Java
access actionlistener add android applet arguments array arrays binary bluetooth c# chat class classes client code combobox compiler component constructor convert coordinates data database db design eclipse error event exception file filei/o forloop givemetehcodez graphics gui helpwithhomework homeworkassignment html ide image input integer interface j2me java jframe jpanel jtextarea julia lazy linked linked-list list loop main method methods mobile netbeans newbie number object objects oracle parameter pattern pixel print printing problem program programming read recursion regex remote remove robot scanner screen search server set size sms socket sort sql string swing system test text transfer translate tree url web windows






