JavaRMI connection to localhost failure - java

I´m starting with RMI.
I wan´t to create a server in Java for a database manger (Is a college thing) and when I run the code listed below, to start the interface for the server, i have a connexion failure with localhost:
By the way, Im Using OS X and Eclipse to code.
/**
*
*/
package es.uned.database;
import es.uned.common.IBasededatos;
import es.uned.common.Utils;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.server.*;
import es.uned.common.IServidor;
/**
*
* #author
*
*/
public class Basededatos extends UnicastRemoteObject implements IBasededatos{
protected Basededatos() throws RemoteException {
super();
// TODO Auto-generated constructor stub
}
public static void main(String[] args) throws Exception {
Utils.setCodeBase(IServidor.class);
if (System.getSecurityManager()==null) {
System.setSecurityManager(new RMISecurityManager());
}
String nombre = "//localhost/Basededatos";
try{
IBasededatos servidorBD = new Basededatos();
Naming.rebind(nombre, servidorBD);
System.out.println("Data base is up an ready");
}catch (Exception e) {
System.err.println("Database exception: " + e.getMessage());
e.printStackTrace();
}
}
}
This is the error message I get.
access denied ("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")
I´ve tried this other code, but with the same success
/**
*
*/
package es.uned.database;
import es.uned.common.IBasededatos;
import es.uned.common.Utils;
import java.rmi.RMISecurityManager;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.*;
/**
*
* #author
*
*/
public class Basededatos implements IBasededatos{
public Basededatos() {
super();
// TODO Auto-generated constructor stub
}
public static void main(String[] args) throws Exception {
//Utils.setCodeBase(IServidor.class);
if (System.getSecurityManager()==null) {
System.setSecurityManager(new RMISecurityManager());
}
String nombre = "//localhost/Basededatos";
try{
IBasededatos servidorBD = new Basededatos();
IBasededatos stub = (IBasededatos)UnicastRemoteObject.exportObject(servidorBD, 1099);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(nombre, servidorBD);
System.out.println("Servidor Base de datos arriba");
}catch (Exception e) {
System.err.println("Excepcion base de datos: " + e.getMessage());
e.printStackTrace();
}
}
}
Can anybody help me?
Thanks a lot

The client is getting the Registry from the wrong place. The Registry it needs to lookup is at the server host, not its own localhost.
RMI URLs are for use with the Naming class. You're using the Registry interface in the client so you shouldn't be specifying //localhost/ at all.

Related

Java RMI issue: Can't solve Exception in thread "main" java.rmi.NotBoundException: Server

I am getting the following error:
Exception in thread "main" java.rmi.NotBoundException: Server
at java.rmi/sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:234)
at java.rmi/sun.rmi.registry.RegistryImpl_Skel.dispatch(RegistryImpl_Skel.java:133)
at java.rmi/sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:468)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:298)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
at java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
at java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:380)
at java.rmi/sun.rmi.registry.RegistryImpl_Stub.lookup(RegistryImpl_Stub.java:123)
at client.RMIClient.startClient(RMIClient.java:17)
at client.FahrradClient.main(FahrradClient.java:12)
Can anybody look at my code and tell me where I went wrong? I'd be more than grateful. Would even send a small tip or something lmao I am that desperate.
package server;
import shared.RMI_Interface;
import java.io.IOException;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class FahrradServer {
public static void main(String[] args) throws IOException, AlreadyBoundException {
RMI_Interface server = new ConfigImpl();
Registry registry = LocateRegistry.createRegistry(1099);
Runtime.getRuntime().exec("rmiregistry 1099");
registry.bind("Server", server);
System.out.println("Server started");
}
}
package client;
import shared.Fahrrad;
import shared.RMI_Interface;
import java.rmi.*;
import java.rmi.registry.*;
public class RMIClient {
private RMI_Interface server;
public RMIClient() {}
public void startClient() throws RemoteException, NotBoundException {
Registry registry = LocateRegistry.getRegistry("localhost", 1099);
server = (RMI_Interface)registry.lookup("Server");
}
public Fahrrad configureFahrrad(String lenkertyp, String material, String schaltung, String griff ) {
Fahrrad result = null;
try {
result = server.configureFahrrad(lenkertyp, material, schaltung, griff);
} catch (RemoteException e) {
e.printStackTrace();
throw new RuntimeException("Could not contact server");
}
return result;
}
}
package server;
import shared.Fahrrad;
import shared.RMI_Interface;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class ConfigImpl implements RMI_Interface {
public void ConfigImpl() throws RemoteException {
UnicastRemoteObject.exportObject(this, 0);
}
#Override
public Fahrrad configureFahrrad(String lenkertyp, String material, String schaltung, String griff ) throws RemoteException {
Fahrrad f = new Fahrrad();
f.setLenkertyp(lenkertyp);
f.setGriff(griff);
f.setMaterial(material);
f.setSchaltung(schaltung);
if (!lenkertyp.equals( "Faltbarlenker") && !lenkertyp.equals( "Rennradlenker") && !lenkertyp.equals( "Bullhornlenker")) {
throw new IllegalArgumentException("Ungültiger Lenktypinput");
}
if (!material.equals( "Aluminium") && !material.equals( "Stahl") && !material.equals( "Kunststoff")){
throw new IllegalArgumentException("Ungültiges Material!");
}
if (!schaltung.equals("Kettenschaltung") && !schaltung.equals( "Tretlagerschaltung") && !lenkertyp.equals( "Nebenschaltung")) {
throw new IllegalArgumentException("Ungültige Schaltung!");
}
if (!griff.equals( "Kunststoffgriff") && !griff.equals( "Ledergriff") && !lenkertyp.equals( "Schaumstoffgriff")) {
throw new IllegalArgumentException("Ungültige Schaltung!");
}
if (lenkertyp.equals("Faltbarlenker") || lenkertyp.equals("Rennradlenker")) {
if (!material.equals( "Aluminium") && !material.equals( "Kunststoff")) {
throw new IllegalArgumentException(lenkertyp + " kann nur aus Aluminium oder Kunststoff bestehen.");
}
}
if (material.equals("Stahl")) {
if (!schaltung.equals("Kettenschaltung")) {
throw new IllegalArgumentException("Materialtyp "+ material + " kann nur Kettenschaltung haben!");
}
}
if (material.equals("Kunststoff")) {
if (griff.equals("Kunststoffgriff")) {
throw new IllegalArgumentException("Nur Kunststoffmaterial kann Kunststoffgriff haben!");
}
}
if (lenkertyp.equals( "Bullhornlenker") || lenkertyp.equals("Faltbarlenker")) {
if (griff.equals("Ledergriff")) {
throw new IllegalArgumentException("Nur Rennladlenker können Ledergriffe haben!");
}
}
return f;
}
}
package server;
import shared.RMI_Interface;
import java.io.IOException;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class FahrradServer{
public static void main(String[] args) throws IOException, AlreadyBoundException {
RMI_Interface server = new ConfigImpl();
Registry registry = LocateRegistry.createRegistry(1099);
Runtime.getRuntime().exec("rmiregistry 1099");
registry.bind("Server", server);
System.out.println("Server started");
}
}
package shared;
public class Fahrrad {
public String lenkertyp;
public String material;
public String schaltung;
public String griff;
public void setLenkertyp(String lenkertyp){
this.lenkertyp=lenkertyp;
}
public String getLenkertyp() {
return lenkertyp;
}
public void setMaterial(String material){
this.material=material;
}
public String getMaterial() {
return material;
}
public void setSchaltung(String schaltung) {
this.schaltung=schaltung;
}
public String getSchaltung() {
return schaltung;
}
public void setGriff(String griff){
this.griff=griff;
}
public String getGriff() {
return griff;
}
}
package shared;
import java.rmi.Remote;
import java.rmi.RemoteException;
// Creating Remote interface for our application
public interface RMI_Interface extends Remote {
public Fahrrad configureFahrrad(String lenkertyp, String material, String schaltung, String griff ) throws RemoteException;
}
I know the code isn't perfect. I will change it but the most important thing is to get the client and server run independently. My client sadly doesn't run.
The steps to follow when creating a RMI application.
Create the "remote" interface.
Your interface RMI_Interface is OK. Nothing to do here.
Create a class that implements the remote interface.
I made the constructor empty. (The rest of the code is unchanged.)
public ConfigImpl() throws RemoteException {
// Empty.
}
Create a RMI server. Here I made a few changes.
package server;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import shared.RMI_Interface;
public class FahrradServer {
public static void main(String[] args) {
try {
ConfigImpl server = new ConfigImpl();
RMI_Interface stub = (RMI_Interface) UnicastRemoteObject.exportObject(server, 0);
Registry registry = LocateRegistry.createRegistry(1099);
registry.bind("Server", stub);
System.out.println("Server started");
}
catch (AlreadyBoundException | RemoteException x) {
x.printStackTrace();
}
}
}
Note that calling method createRegistry() will launch the rmiregistry so no need for this line of your code:
Runtime.getRuntime().exec("rmiregistry 1099");
Run the server, i.e. java server.FahrradServer
(I assume you know the correct command that you need to actually launch your server.)
Note that the server program will run forever – unless you kill it.
Write the client. The client will run in a separate JVM so the client needs a main() method so that you can launch it via the java command.
package client;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import shared.Fahrrad;
import shared.RMI_Interface;
public class RMIClient {
private RMI_Interface server;
public void startClient() throws RemoteException, NotBoundException {
Registry registry = LocateRegistry.getRegistry(1099);
server = (RMI_Interface) registry.lookup("Server");
}
public Fahrrad configureFahrrad(String lenkertyp,
String material,
String schaltung,
String griff) throws RemoteException {
return server.configureFahrrad(lenkertyp, material, schaltung, griff);
}
public static void main(String[] args) {
RMIClient client = new RMIClient();
try {
client.startClient();
Fahrrad f = client.configureFahrrad("Faltbarlenker",
"Aluminium",
"Kettenschaltung",
"Kunststoffgriff");
System.out.println("Fahrrad: " + f);
}
catch (RemoteException | NotBoundException x) {
x.printStackTrace();
}
}
}
Since the return value of the remote interface method is a class that you wrote, that class must implement interface Serializable, i.e.
public class Fahrrad implements java.io.Serializable
Now you can launch your RMI client, e.g. java client.RMIClient
Refer to the RMI trail of Oracle's java tutorials.

Constantly receive java.lang.ClassNotFoundException

I am very new to Java and the RMI system. I am following a tutorial but I am unsure why I keep getting the following errors[1]
[1]: https://i.stack.imgur.com/xeYTn.png
I have attached the code (taken directly from the tutorial here: https://docs.oracle.com/javase/1.5.0/docs/guide/rmi/hello/hello-world.html)
I have tried:
removing any lines with 'package'
changing classpath variables
reinstalling java and javac
setting classpath in the 'rmiregistry &' command
Any help would be appreciated
edit: forgot to attach the code.
Hello.java
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}
Client.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class Client {
private Client() {
}
public static void main(String[] args) {
String host = (args.length < 1) ? null : args[0];
try {
Registry registry = LocateRegistry.getRegistry(host);
Hello stub = (Hello) registry.lookup("Hello");
String response = stub.sayHello();
System.out.println("response: " + response);
} catch (Exception e) {
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}
}
}
Server.java
import java.rmi.registry.Registry;
import java.rmi.registry.LocateRegistry;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class Server implements Hello {
public Server() {
}
public String sayHello() {
return "Hello, world!";
}
public static void main(String args[]) {
try {
Server obj = new Server();
Hello stub = (Hello) UnicastRemoteObject.exportObject((Remote) obj, 0);
// Bind the remote object's stub in the registry
Registry registry = LocateRegistry.getRegistry();
registry.bind("Hello", stub);
System.err.println("Server ready");
} catch (Exception e) {
System.err.println("Server exception: " + e.toString());
e.printStackTrace();
}
}
}
You have to run the command rmiregistry & in the folder the code is compiled into. In this case, "files"
the "getting started" tutorial didn't mention that.

how to test RMI program in java

As I'm trying to achieve my first RMI program, I'm having troubles testing it.
I compiled my programs and tried to launch my server but an error then occurs.
About my server: 1 interface + 1 class implementing it + my server class
Interface
package src;
import java.rmi.*;
public interface Information extends Remote {
// methods than can be called remotly
public String getInformation() throws RemoteException;
}
Class Implementing it
package src;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
public class InformationImpl extends UnicastRemoteObject implements Information {
protected InformationImpl() throws RemoteException {
super();
}
public String getInformation() throws RemoteException {
System.out.println("method getInformation()");
return "hello";
}
}
My server class :
package src;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
public class LanceServeur {
public static void main(String[] args) {
try {
LocateRegistry.createRegistry(1099);
InformationImpl informationImpl = new InformationImpl();
Naming.rebind("MyServer", informationImpl);
System.out.println("Server launched");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
And my client class :
package src;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
public class lanceClient {
public static void main(String[] args) {
System.out.println("Lancement du client");
try {
Remote r = Naming.lookup("rmi://localhost:1099/TestRMI");
System.out.println(r);
if (r instanceof Information) {
String s = ((Information) r).getInformation();
System.out.println("chaine renvoyee = " + s);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (NotBoundException e) {
e.printStackTrace();
}
System.out.println("end of client");
}
}
If you want to see the correct lines, check my github it's easier :
https://github.com/TLprojet/MUD_Java
About the error, here it is:
java.rmi.ConnectIOException: Exception creating connection to: 0.0.21.214; nested exception is:
java.net.SocketException: Invalid argument or cannot assign requested address
at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:631)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:209)
at java.rmi/sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:196)
at java.rmi/sun.rmi.server.UnicastRef.newCall(UnicastRef.java:338)
at java.rmi/sun.rmi.registry.RegistryImpl_Stub.rebind(RegistryImpl_Stub.java:147)
at java.rmi/java.rmi.Naming.rebind(Naming.java:177)
at src.LanceServeur.main(LanceServeur.java:16)
Caused by: java.net.SocketException: Invalid argument or cannot assign requested address
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
at java.base/java.net.Socket.connect(Socket.java:591)
at java.base/java.net.Socket.connect(Socket.java:540)
at java.base/java.net.Socket.<init>(Socket.java:436)
at java.base/java.net.Socket.<init>(Socket.java:213)
at java.rmi/sun.rmi.transport.tcp.TCPDirectSocketFactory.createSocket(TCPDirectSocketFactory.java:40)
at java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 6 more

RMI on Raspberry Pi not working Connection refused to host : 127.0.0.1

I am trying to communicate between server (on Pi) and client (on another PI) using java RMI. The Client is able to call the remote methods of the Server but when Server tries to access the remote method of client I get the error of Connection refused to Host 127.0.0.1. To solve this I set the System.setProperty("java.rmi.server.hostname", ServerIP; but then get the error of Connection refused to Host 10.10.*.*.
The MasterInterface looks like
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface MasterInterface extends Remote{
public void sayHello(String s) throws RemoteException;
}
The Master.java file looks like
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class Master extends UnicastRemoteObject implements MasterInterface{
protected Master() throws RemoteException {
super();
// TODO Auto-generated constructor stub
}
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
System.setProperty("java.rmi.server.hostname", "192.168.4.*");
Master master = new Master();
Registry reg = LocateRegistry.createRegistry(9898);
reg.rebind("Master", master);
System.out.println("Master is on.123123132.test.");
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
#Override
public void sayHello(String s) throws RemoteException {
// TODO Auto-generated method stub
System.out.println("Hiiiiiii ->>>>>"+s);
try{
Registry regi2 = LocateRegistry.getRegistry("192.168.*.*", 9898);
System.out.println("asdasdasd1!!");
SlaveInterface bsObj1 = (SlaveInterface) regi2.lookup("Slave");
bsObj1.saybye("madhav");
}catch(Exception e){
e.printStackTrace();
}
}
}
The SlaveInterface looks like
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface SlaveInterface extends Remote{
public void saybye(String s) throws RemoteException;
}
The Slave.java files look like
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class Slave extends UnicastRemoteObject implements SlaveInterface {
private final static String master_IP = "192.168.4.*";
protected Slave() throws RemoteException {
super();
// TODO Auto-generated constructor stub
}
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* #param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
System.setProperty("java.rmi.server.hostname", "192.168.*.*");
Slave s = new Slave();
Registry regclient = LocateRegistry.createRegistry(2525);
System.out.println("slave obj bound!!");
regclient.rebind("Slave", s);
System.out.println("Slave is on..");
Registry regi = LocateRegistry.getRegistry(master_IP, 9898);
System.out.println("slave obj bound1111!!");
MasterInterface bsObj = (MasterInterface) regi.lookup("Master");
System.out.println("slave obj bound2222!!");
bsObj.sayHello("hi karan");
System.out.println("done................");
}catch(Exception e){
System.out.println("not working!!!!!!!!!!");
e.printStackTrace();
}
}
#Override
public void saybye(String s) throws RemoteException {
// TODO Auto-generated method stub
System.out.println("bye "+s);
}
}
Set java.rmi.server.hostname to the extermal IP address of the server in the server JVM before exporting any remote objects. See the RMI FAQ item A.1.
Had this problem a few year ago, because of the name resolution (by default the hostname will resolve to 127.0.0.1 - the IP address of the loopback interface).
If you do not have a DNS server, try this:
Assign to both Pi a different hostname (set it in /etc/hostname) or use the hostname command.
If you use for example "master" and "client" as hostnames, and 10.10.10.13 and 10.10.10.14 are their IP addresses, add the following information to the file /etc/hosts, in both Pi:
10.10.10.13 master
10.10.10.14 client

java.net.connectexception connection timeout

hi i am using this codes for rmi
RmiServer.java
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;
import java.net.*;
public class RmiServer extends java.rmi.server.UnicastRemoteObject
implements ReceiveMessageInterface
{
int thisPort;
String thisAddress;
Registry registry; // rmi registry for lookup the remote objects.
// This method is called from the remote client by the RMI.
// This is the implementation of the gReceiveMessageInterfaceh.
public void receiveMessage(String x) throws RemoteException
{
System.out.println(x);
}
public RmiServer() throws RemoteException
{
try{
// get the address of this host.
thisAddress= (InetAddress.getLocalHost()).toString();
}
catch(Exception e){
throw new RemoteException("can't get inet address.");
}
thisPort=3232; // this port(registryfs port)
System.out.println("this address="+thisAddress+",port="+thisPort);
try{
// create the registry and bind the name and object.
registry = LocateRegistry.createRegistry( thisPort );
registry.rebind("rmiServer", this);
}
catch(RemoteException e){
throw e;
}
}
static public void main(String args[])
{
try{
RmiServer s=new RmiServer();
}
catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}
RmiClient.java
import java.rmi.*;
import java.rmi.registry.*;
import java.net.*;
public class RmiClient
{
static public void main(String args[])
{
ReceiveMessageInterface rmiServer;
Registry registry;
String serverAddress=args[0];
String serverPort=args[1];
String text=args[2];
System.out.println("sending "+text+" to "+serverAddress+":"+serverPort);
try{
// get the �gregistry�h
registry=LocateRegistry.getRegistry(
serverAddress,
(new Integer(serverPort)).intValue()
);
// look up the remote object
rmiServer=
(ReceiveMessageInterface)(registry.lookup("rmiServer"));
// call the remote method
rmiServer.receiveMessage(text);
}
catch(RemoteException e){
e.printStackTrace();
}
catch(NotBoundException e){
e.printStackTrace();
}
}
}
ReceiveMessageInterface.java
import java.rmi.*;
public interface ReceiveMessageInterface extends Remote
{
public void receiveMessage(String x) throws RemoteException;
}
This works fine normally , but when the a computer is connected to internet through mobile or it shares internet from other pc it doesn't work
I get this error.
java.net.connectexception connection timeout
when i tried to telnet it fails to connect but when i try to run this program that pc
to my pc it works.
Please let me know how to solve this issue.
Sounds like a firewall or proxy server issue.

Categories